Version Notes
1. Fixed potential conflicts with other module.
2. Supported php 7.x
Download this release
Release Info
Developer | Ray |
Extension | Rayfox_Catalog |
Version | 0.2.5 |
Comparing to | |
See all releases |
Code changes from version 0.2.1 to 0.2.5
- app/code/community/Rayfox/.DS_Store +0 -0
- app/code/community/Rayfox/Catalog/.DS_Store +0 -0
- app/code/community/Rayfox/Catalog/Helper/Data.php +28 -13
- app/code/community/Rayfox/Catalog/Model/.DS_Store +0 -0
- app/code/community/Rayfox/Catalog/Model/Layer.php +38 -20
- app/code/community/Rayfox/Catalog/Model/Search/Advanced.php +38 -0
- app/code/community/Rayfox/Catalog/Model/Search/Layer.php +23 -18
- app/code/community/Rayfox/Catalog/etc/config.xml +26 -25
- app/code/community/Rayfox/Catalog/etc/system.xml +19 -19
- package.xml +8 -7
app/code/community/Rayfox/.DS_Store
ADDED
Binary file
|
app/code/community/Rayfox/Catalog/.DS_Store
CHANGED
Binary file
|
app/code/community/Rayfox/Catalog/Helper/Data.php
CHANGED
@@ -9,20 +9,35 @@
|
|
9 |
* 3. Support both configurable and simple products now.
|
10 |
* This source file is subject to the Open Software License (OSL 3.0)
|
11 |
*
|
12 |
-
* @version 0.2.
|
13 |
*/
|
14 |
class Rayfox_Catalog_Helper_Data extends Mage_CatalogInventory_Helper_Data
|
15 |
{
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
* 3. Support both configurable and simple products now.
|
10 |
* This source file is subject to the Open Software License (OSL 3.0)
|
11 |
*
|
12 |
+
* @version 0.2.5
|
13 |
*/
|
14 |
class Rayfox_Catalog_Helper_Data extends Mage_CatalogInventory_Helper_Data
|
15 |
{
|
16 |
+
const XML_PATH_SORT_OUT_OF_STOCK = 'cataloginventory/options/sort_out_of_stock_at_bottom';
|
17 |
+
const XML_PATH_SORT_OUT_OF_STOCK_SEARCH_RESULT = 'cataloginventory/options/sort_out_of_stock_at_bottom_for_search';
|
18 |
+
|
19 |
+
public function isSortOutOfStockProductsAtBottomEnabled()
|
20 |
+
{
|
21 |
+
return $this->isShowOutOfStock() && Mage::getStoreConfigFlag(self::XML_PATH_SORT_OUT_OF_STOCK);
|
22 |
+
}
|
23 |
|
24 |
+
public function isEnabledForSearchResults()
|
25 |
+
{
|
26 |
+
return $this->isShowOutOfStock() && Mage::getStoreConfigFlag(self::XML_PATH_SORT_OUT_OF_STOCK_SEARCH_RESULT);
|
27 |
+
}
|
28 |
+
|
29 |
+
public function checkFieldExisted($select, $field)
|
30 |
+
{
|
31 |
+
$result = false;
|
32 |
+
if($field) {
|
33 |
+
$columns = $select->getPart(Zend_Db_Select::COLUMNS);
|
34 |
+
foreach ($columns as $column) {
|
35 |
+
if (in_array($field , $column)) {
|
36 |
+
$result = true;
|
37 |
+
break;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
return $result;
|
42 |
+
}
|
43 |
+
}
|
app/code/community/Rayfox/Catalog/Model/.DS_Store
CHANGED
Binary file
|
app/code/community/Rayfox/Catalog/Model/Layer.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Sort products by stock status.
|
4 |
*
|
@@ -9,27 +10,44 @@
|
|
9 |
* 3. Support both configurable and simple products now.
|
10 |
* This source file is subject to the Open Software License (OSL 3.0)
|
11 |
*
|
12 |
-
* @version 0.2.
|
13 |
*/
|
14 |
class Rayfox_Catalog_Model_Layer extends Mage_Catalog_Model_Layer
|
15 |
{
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
}
|
22 |
-
$websiteId = Mage::app()->getStore()->getWebsiteId();
|
23 |
-
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
|
24 |
-
$collection->joinTable(
|
25 |
-
array('cisi' => 'cataloginventory/stock_status'),
|
26 |
-
'product_id=entity_id',
|
27 |
-
'stock_status',
|
28 |
-
array('website_id'=> $websiteId),
|
29 |
-
'left'
|
30 |
-
);
|
31 |
}
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Sort products by stock status.
|
5 |
*
|
10 |
* 3. Support both configurable and simple products now.
|
11 |
* This source file is subject to the Open Software License (OSL 3.0)
|
12 |
*
|
13 |
+
* @version 0.2.5
|
14 |
*/
|
15 |
class Rayfox_Catalog_Model_Layer extends Mage_Catalog_Model_Layer
|
16 |
{
|
17 |
+
public function prepareProductCollection($collection)
|
18 |
+
{
|
19 |
+
parent::prepareProductCollection($collection);
|
20 |
+
if (!Mage::helper('rayfox_catalog')->isSortOutOfStockProductsAtBottomEnabled()) {
|
21 |
+
return $this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
+
try {
|
24 |
+
$websiteId = Mage::app()->getStore()->getWebsiteId();
|
25 |
+
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
|
26 |
+
|
27 |
+
/*$collection->getSelect()->joinLeft(
|
28 |
+
array('stock_status' => 'cataloginventory_stock_status'),
|
29 |
+
'stock_status.product_id = e.entity_id',
|
30 |
+
array('stock_status')
|
31 |
+
);*/
|
32 |
+
|
33 |
+
// fix conflict
|
34 |
+
// check if stock_status field already joined (for example, by other extensions)
|
35 |
+
$stockStatusFieldExisted = Mage::helper('rayfox_catalog')->checkFieldExisted($collection->getSelect(), 'stock_status');
|
36 |
+
//if yes, skip join.
|
37 |
+
if(!$stockStatusFieldExisted) {
|
38 |
+
$collection->joinTable(
|
39 |
+
array('cisi' => 'cataloginventory/stock_status'),
|
40 |
+
'product_id=entity_id',
|
41 |
+
array('stock_status'),
|
42 |
+
array('website_id' => $websiteId),
|
43 |
+
'left'
|
44 |
+
);
|
45 |
+
|
46 |
+
}
|
47 |
+
}
|
48 |
+
$collection->getSelect()->order('stock_status desc');
|
49 |
+
}
|
50 |
+
catch (Exception $e) {}
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Rayfox/Catalog/Model/Search/Advanced.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sort products by stock status.
|
4 |
+
*
|
5 |
+
* Features:
|
6 |
+
* 1. Always show out of stock products on the bottom of the category page.
|
7 |
+
* 2. Easy setup, just turn on from Magento backend, and it works!
|
8 |
+
* 2. Configurable settings, it depends on "show out of stock product", it will be hidden if not allowed display out of stock products.
|
9 |
+
* 3. Support both configurable and simple products now.
|
10 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
11 |
+
*
|
12 |
+
* @version 0.2.5
|
13 |
+
*/
|
14 |
+
class Rayfox_Catalog_Model_Search_Advanced extends Mage_CatalogSearch_Model_Advanced
|
15 |
+
{
|
16 |
+
public function prepareProductCollection($collection)
|
17 |
+
{
|
18 |
+
parent::prepareProductCollection($collection);
|
19 |
+
if(!Mage::helper('rayfox_catalog')->isEnabledForSearchResults()){
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
$websiteId = Mage::app()->getStore()->getWebsiteId();
|
23 |
+
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
|
24 |
+
$stockStatusFieldExisted = Mage::helper('rayfox_catalog')->checkFieldExisted($collection->getSelect(), 'stock_status');
|
25 |
+
if(!$stockStatusFieldExisted) {
|
26 |
+
$collection->joinTable(
|
27 |
+
array('cisi' => 'cataloginventory/stock_status'),
|
28 |
+
'product_id=entity_id',
|
29 |
+
array('stock_status'),
|
30 |
+
array('website_id'=> $websiteId),
|
31 |
+
'left'
|
32 |
+
);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
$collection->getSelect()->order('stock_status desc');
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Rayfox/Catalog/Model/Search/Layer.php
CHANGED
@@ -9,27 +9,32 @@
|
|
9 |
* 3. Support both configurable and simple products now.
|
10 |
* This source file is subject to the Open Software License (OSL 3.0)
|
11 |
*
|
12 |
-
* @version 0.2.
|
13 |
*/
|
14 |
class Rayfox_Catalog_Model_Search_Layer extends Mage_CatalogSearch_Model_Layer
|
15 |
{
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
$websiteId = Mage::app()->getStore()->getWebsiteId();
|
23 |
-
|
24 |
-
$collection->
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
$collection->getSelect()->order('stock_status desc');
|
33 |
-
|
34 |
-
|
35 |
-
}
|
9 |
* 3. Support both configurable and simple products now.
|
10 |
* This source file is subject to the Open Software License (OSL 3.0)
|
11 |
*
|
12 |
+
* @version 0.2.5
|
13 |
*/
|
14 |
class Rayfox_Catalog_Model_Search_Layer extends Mage_CatalogSearch_Model_Layer
|
15 |
{
|
16 |
+
public function prepareProductCollection($collection)
|
17 |
+
{
|
18 |
+
parent::prepareProductCollection($collection);
|
19 |
+
if(!Mage::helper('rayfox_catalog')->isEnabledForSearchResults()){
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
$websiteId = Mage::app()->getStore()->getWebsiteId();
|
23 |
+
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
|
24 |
+
$stockStatusFieldExisted = Mage::helper('rayfox_catalog')->checkFieldExisted($collection->getSelect(), 'stock_status');
|
25 |
+
|
26 |
+
if(!$stockStatusFieldExisted) {
|
27 |
+
$collection->joinTable(
|
28 |
+
array('cisi' => 'cataloginventory/stock_status'),
|
29 |
+
'product_id=entity_id',
|
30 |
+
array('stock_status'),
|
31 |
+
array('website_id'=> $websiteId),
|
32 |
+
'left'
|
33 |
+
);
|
34 |
+
}
|
35 |
+
|
36 |
}
|
37 |
$collection->getSelect()->order('stock_status desc');
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Rayfox/Catalog/etc/config.xml
CHANGED
@@ -26,28 +26,29 @@
|
|
26 |
*/
|
27 |
-->
|
28 |
<config>
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
</
|
|
26 |
*/
|
27 |
-->
|
28 |
<config>
|
29 |
+
<modules>
|
30 |
+
<Rayfox_Catalog>
|
31 |
+
<version>0.2.5</version>
|
32 |
+
</Rayfox_Catalog>
|
33 |
+
</modules>
|
34 |
+
<global>
|
35 |
+
<models>
|
36 |
+
<catalog>
|
37 |
+
<rewrite>
|
38 |
+
<layer>Rayfox_Catalog_Model_Layer</layer>
|
39 |
+
</rewrite>
|
40 |
+
</catalog>
|
41 |
+
<catalogsearch>
|
42 |
+
<rewrite>
|
43 |
+
<layer>Rayfox_Catalog_Model_Search_Layer</layer>
|
44 |
+
<advanced>Rayfox_Catalog_Model_Search_Advanced</advanced>
|
45 |
+
</rewrite>
|
46 |
+
</catalogsearch>
|
47 |
+
</models>
|
48 |
+
<helpers>
|
49 |
+
<rayfox_catalog>
|
50 |
+
<class>Rayfox_Catalog_Helper</class>
|
51 |
+
</rayfox_catalog>
|
52 |
+
</helpers>
|
53 |
+
</global>
|
54 |
+
</config>
|
app/code/community/Rayfox/Catalog/etc/system.xml
CHANGED
@@ -26,21 +26,21 @@
|
|
26 |
*/
|
27 |
-->
|
28 |
<config>
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
<sort_out_of_stock_at_bottom_for_search>
|
45 |
<label>Enabled for search results</label>
|
46 |
<frontend_type>select</frontend_type>
|
@@ -51,10 +51,10 @@
|
|
51 |
<show_in_website>1</show_in_website>
|
52 |
<show_in_store>1</show_in_store>
|
53 |
</sort_out_of_stock_at_bottom_for_search>
|
54 |
-
|
55 |
-
|
56 |
</groups>
|
57 |
-
|
58 |
-
|
59 |
</config>
|
60 |
|
26 |
*/
|
27 |
-->
|
28 |
<config>
|
29 |
+
<sections>
|
30 |
+
<cataloginventory>
|
31 |
+
<groups>
|
32 |
+
<options translate="label">
|
33 |
+
<fields>
|
34 |
+
<sort_out_of_stock_at_bottom>
|
35 |
+
<label>Out of Stock Products At Bottom</label>
|
36 |
+
<frontend_type>select</frontend_type>
|
37 |
+
<depends><show_out_of_stock>1</show_out_of_stock></depends>
|
38 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
39 |
+
<sort_order>999</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>1</show_in_website>
|
42 |
+
<show_in_store>1</show_in_store>
|
43 |
+
</sort_out_of_stock_at_bottom>
|
44 |
<sort_out_of_stock_at_bottom_for_search>
|
45 |
<label>Enabled for search results</label>
|
46 |
<frontend_type>select</frontend_type>
|
51 |
<show_in_website>1</show_in_website>
|
52 |
<show_in_store>1</show_in_store>
|
53 |
</sort_out_of_stock_at_bottom_for_search>
|
54 |
+
</fields>
|
55 |
+
</options>
|
56 |
</groups>
|
57 |
+
</cataloginventory>
|
58 |
+
</sections>
|
59 |
</config>
|
60 |
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Rayfox_Catalog</name>
|
4 |
-
<version>0.2.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -18,11 +18,12 @@
|
|
18 |
<li> Configurable settings, it depends on &quot;show out of stock product&quot;, it will be hidden if not allowed display out of stock products. </li>
|
19 |
<li>Support both configurable and simple products now.</li>
|
20 |
</ul></description>
|
21 |
-
<notes>
|
22 |
-
|
23 |
-
<
|
24 |
-
<
|
25 |
-
<
|
|
|
26 |
<compatible/>
|
27 |
-
<dependencies><required><php><min>5.
|
28 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Rayfox_Catalog</name>
|
4 |
+
<version>0.2.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
18 |
<li> Configurable settings, it depends on &quot;show out of stock product&quot;, it will be hidden if not allowed display out of stock products. </li>
|
19 |
<li>Support both configurable and simple products now.</li>
|
20 |
</ul></description>
|
21 |
+
<notes>1. Fixed potential conflicts with other module.
|
22 |
+
2. Supported php 7.x</notes>
|
23 |
+
<authors><author><name>Ray</name><user>cgzhang</user><email>cgzhang@gmail.com</email></author></authors>
|
24 |
+
<date>2016-11-18</date>
|
25 |
+
<time>06:36:02</time>
|
26 |
+
<contents><target name="magecommunity"><dir name="Rayfox"><dir name="Catalog"><dir name="Helper"><file name="Data.php" hash="c1048df6ce1472a3455e033ace61c149"/></dir><dir name="Model"><file name="Layer.php" hash="6a070a1ca34d9675f0a35ab1036010bc"/><dir name="Search"><file name="Advanced.php" hash="064994639a76217c89a4e5f2030da030"/><file name="Layer.php" hash="47342d24e3f9c367018bffc95b8e4ba2"/></dir><file name=".DS_Store" hash="d6ea1718d9ba907d809e80993b2e7097"/></dir><dir name="etc"><file name="config.xml" hash="bed52ac8f8cc3d15cb721b667f9497cf"/><file name="system.xml" hash="f20baf7c4a446856f083f404a4a3d185"/></dir><file name=".DS_Store" hash="77abca31ed0bb69e5f9d89a3c92819d9"/></dir><file name=".DS_Store" hash="20e61045f5561df8f8bf3c313b1461a1"/></dir></target><target name="mageetc"><dir name="modules"><file name="Rayfox_Catalog.xml" hash="45279cdc4ceec7308127aae41ec7badd"/></dir></target></contents>
|
27 |
<compatible/>
|
28 |
+
<dependencies><required><php><min>5.0.0</min><max>7.1.0</max></php></required></dependencies>
|
29 |
</package>
|