Magento allows sorting by Position, Price and Name in the toolbar.
But It does not look at the status of product and if the product is available. Under normal circumstances, I would not like to show any of the products which are not available but due to SEO reasons, it makes sense to continue showing the products. So I would like to continue showing the products based on one of the sorting method but pushing the out-of-stock product at the end.
To do this a good post is http://www.magentocommerce.com/boards/viewthread/203590/#t345652
A more elegant solution is to make changes in .../Mage/Catalog/Model/Layer.php at line #102
$collection->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')->setOrder('inventory_in_stock', 'desc');
This will effect both the listing as well as the results page.
Another things is to remember to copy this file from core to code/local//Mage/Catalog/Model/Layer.php so that the core files remain as it is.
But It does not look at the status of product and if the product is available. Under normal circumstances, I would not like to show any of the products which are not available but due to SEO reasons, it makes sense to continue showing the products. So I would like to continue showing the products based on one of the sorting method but pushing the out-of-stock product at the end.
To do this a good post is http://www.magentocommerce.com/boards/viewthread/203590/#t345652
A more elegant solution is to make changes in .../Mage/Catalog/Model/Layer.php at line #102
$collection->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')->setOrder('inventory_in_stock', 'desc');
This will effect both the listing as well as the results page.
Another things is to remember to copy this file from core to code/local//Mage/Catalog/Model/Layer.php so that the core files remain as it is.
it works fine but didn't work on price sort any clue
ReplyDeletehow can we make it to work on price ?
ReplyDeleteDoes not work with bundle
ReplyDeleteIn Bundle the inventory is choosen dynamically and hence does not work as it expects the attribute stock to be set.
ReplyDeleteIf you want to make bundles work, you will need to manage the bundle inventory manually, which will also painful.
hello
ReplyDeletethank you for the so useful post
stock status for products is a very important part of ecommerce.
to simplify manage products status
http://amasty.com/custom-stock-status.html