I want to show out of stock products at the end of product search results page. I have tried to do that by using some free extension/code but none of code didn't worked for search results page. please suggest me how can I do that.

1 Answer 1


Sorry if solution isn't very clean. I just copied from one of the modules which has been written many years ago...



Observer method:

public function catalogProductSort($observer) {
    $collection = $observer->getEvent()->getCollection();

    if ( !($collection instanceof Mage_Catalog_Model_Resource_Product_Collection)
        || !Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')
    ) {
        return ;

    $allowedClasses = array(
    if ( !in_array( get_class($collection), $allowedClasses) ) {
        return ;


    $select = $collection->getSelect();
    $orders = $select->order( 'is_in_stock '.Zend_Db_Select::SQL_DESC)
    array_unshift($orders, array_pop($orders));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.