我想重写核心CatalogSearch模块中图层的“PrepareProductCollection”功能。这是我写的:
文件路径:Company/Module/Model/CatalogSearch/Layer.php
class Company_Module_Model_CatalogSearch_Layer extends Mage_CatalogSearch_Model_Layer
{
public function prepareProductCollection($collection)
{
parent::prepareProductCollection($collection);
Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($collection);
$collection->getSelect()->order('is_in_stock desc');
return $this;
}
}
在配置文件中:
<config>
<modules>
<Company_Module>
<version>0.0.0.1</version>
<Company_Module>
</modules>
<global>
<models>
<module>
<class>Company_Module_Model</class>
</module>
<catalogsearch>
<rewrite>
<layer>Company_Module_Model_CatalogSearch_Layer</layer>
</rewrite>
</catalogsearch>
</models>
</global>
</config>
我想我可能遗漏了什么?有人能帮我吗?
最佳答案
您错过了在config.xml中结束catalogsearch
标记