The product list pages are currently set to show out of stock products. I would like to show these products after the In Stock items. Thanks.


You can use catalog_product_collection_load_before event.

And in the observer:

public function modifyProductCollection(Varien_Event_Observer $observer) {
    $collection = $observer->getCollection();

                array('_inventory_table' => $collection->getTable('cataloginventory/stock_item')),
                "_inventory_table.product_id = e.entity_id",
            ->order('is_in_stock DESC')
            ->order('created_at DESC');

Note: Tested on, I guess it will work on 1.8, too.

|improve this answer|||||
  • The disadvantage to this approach is that not all out of stock products will be in the correct position as the is_in_stock entry doesn't take isSalable in account. – Toon Van Dooren Dec 5 '13 at 12:56
  • Sorry, I'm still learning how all of this works. Where do I need to make these changes? – bezz Dec 5 '13 at 14:27
  • You will need a new module for this. Search on the net for creating module with observer, there are many tutorials. – enenen Dec 6 '13 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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