php – Magento – CatalogSearch模块覆盖不起作用
发布时间:2020-12-13 22:47:38 所属栏目:PHP教程 来源:网络整理
导读:我想覆盖核心CatalogSearch模块中图层的“prepareProductCollection”功能.这就是我写的: 文件路径:公司/模块/模型/ CatalogSearch / Layer.php class Company_Module_Model_CatalogSearch_Layer extends Mage_CatalogSearch_Model_Layer{public function
我想覆盖核心CatalogSearch模块中图层的“prepareProductCollection”功能.这就是我写的:
文件路径:公司/模块/模型/ 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标记
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |