加入以下代码:
<?php class Rayfox_Catalog_Model_Layer extends Mage_Catalog_Model_Layer { public function prepareProductCollection($collection) { if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) { Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($collection); } $collection->getSelect()->order('is_in_stock desc'); //Mage::log($collection->getSelect() . ''); return parent::prepareProductCollection($collection); } };