I am using Magento 1.7.0.2 and I have this code line that i am using in /app/code/core/Mage/Catalog/Block/Product/list.php :
$this->_productCollection = $layer->getProductCollection()
->joinField(
'inventory_in_stock',
'cataloginventory_stock_item',
'is_in_stock',
'product_id=entity_id',
'is_in_stock>=0',
'left')
->setOrder('inventory_in_stock','desc');
When sorting for position and name the out of stock products are last. But when sorting for price, the out of stock products are in a normal order not last.
How can i make that the out of stock products to be last even in the sort after price ?
Best Answer
Great find Alex! A tip: If you want to avoid changing core files (and possibly make this into a module), you can add it to an event listener, like this (tested on 1.8.1.0):
Edit: Changed back to catalog_product_collection_load_before from catalog_product_collection_apply_limitations_before and fixed order part priority.