Magento – How to Show Out Of Stock Products at the end of product list in any sorting condition in magento 1.9

magento-1.9out-of-stock

I am using Magento 1.9 , to display out of stock products at the end of product list i have replaced the code

<?php
    $this->_productCollection = $layer->getProductCollection();
?>

With

<?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');
?>

in app/code/core/Mage/catelog/Block/product/list.php
now products 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 ?Please help me find out this solution.

Best Answer

You can use solution 2 of this answer. it worked for me:

of this solution. it worked for me: https://magento.stackexchange.com/a/32950

Related Topic