0
在庫切れの商品が在庫切れの商品の前に表示されるように、カテゴリページで商品のコレクションをソートしたいと思います。在庫切れの商品はすべて在庫切れ商品の後に表示されます。私は既にMage_Product_Block_Listブロックを書き換えました。商品の在庫をマゼンタの在庫状況で並べ替える方法
在庫切れの商品が在庫切れの商品の前に表示されるように、カテゴリページで商品のコレクションをソートしたいと思います。在庫切れの商品はすべて在庫切れ商品の後に表示されます。私は既にMage_Product_Block_Listブロックを書き換えました。商品の在庫をマゼンタの在庫状況で並べ替える方法
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');
}
ありがとうございました。 –