문제

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) {
    //catalog_product_collection_load_before
    $collection = $observer->getCollection();

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

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top