Created
January 5, 2016 11:31
-
-
Save ViniciusAugusto/ed211ab575256014aa04 to your computer and use it in GitHub Desktop.
Sem estoque, por ultimo na listagem de produtos - Magento 1.7.0.0 +
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// insira o codigo abaixo para colocar os produtos sem estoque por ultimo na listagem de produtos do magento | |
// depois de | |
if ($attribute == 'price' && $storeId != 0) { | |
//no arquivo app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php se a versão do Magento 1.7.0.0 + | |
//alteração | |
$this->getSelect()->joinLeft( | |
array('_inventory_table'=>$this->getTable('cataloginventory/stock_item')), | |
"_inventory_table.product_id = e.entity_id", | |
array('is_in_stock', 'manage_stock') | |
); | |
$this->addExpressionAttributeToSelect('on_top', | |
'(CASE WHEN (((_inventory_table.use_config_manage_stock = 1) AND (_inventory_table.is_in_stock = 1)) OR ((_inventory_table.use_config_manage_stock = 0) AND (1 - _inventory_table.manage_stock + _inventory_table.is_in_stock >= 1))) THEN 1 ELSE 0 END)', | |
array()); | |
$this->getSelect()->order('on_top DESC'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment