Magento-模型重写在本地代码中不起作用 [英] Magento - Model Override Not Working in local codePool
问题描述
我试图覆盖Magento 1.9的目录层类,以便长时间找不到错误后才起作用:(
I'm trying to override the Catalog Layer class of Magento 1.9 so that not working after longs times to find error :(
日志中没有错误,除模型重写外,模块均正常工作.
No errors in logs, module work correctly except model rewrite.
app/etc/modules/comx_fab.xml:
app/etc/modules/comx_fab.xml:
<?xml version="1.0"?>
<config>
<modules>
<Comx_Fab>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Catalog />
</depends>
</Comx_Fab>
</modules>
</config>
app/code/local/Comx/Fab/etc/config.xml:
app/code/local/Comx/Fab/etc/config.xml:
<?xml version="1.0"?>
<config>
<modules>
<Comx_Fab>
<version>0.2.0</version>
</Comx_Fab>
</modules>
<global>
<blocks>
<catalog>
<rewrite>
<product_list_toolbar>Comx_Fab_Catalog_Block_Product_List_Toolbar</product_list_toolbar>
</rewrite>
</catalog>
<page>
<rewrite>
<html_topmenu>Comx_Fab_Page_Block_Html_Topmenu</html_topmenu>
</rewrite>
</page>
</blocks>
<models>
<catalog>
<rewrite>
<layer>Comx_Fab_Catalog_Model_Layer</layer>
</rewrite>
</catalog>
</models>
</global>
</config>
app/code/local/Comx/Fab/Catalog/Model/Layer.php:
app/code/local/Comx/Fab/Catalog/Model/Layer.php:
<?php
class Comx_Fab_Catalog_Model_Layer extends Mage_Catalog_Model_Layer {
/**
* Initialize product collection
*
* @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
* @return Mage_Catalog_Model_Layer
*/
public function prepareProductCollection($collection) {
exit('Good!');
}
}
已经完成:
- 刷新缓存,删除缓存"文件夹,
- 将我的magento代码与当前的magento版本进行比较(无差异)
- 检查所有者/chmod
推荐答案
找到了! :)
扩展名冲突!
如何解决:
- 检查扩展名与此免费的magento模块冲突: https://marketplace .magento.com/alekseon-modules-conflict-detector.html
- 找到冲突的扩展名并使用一种解决方案(请阅读底部的我如何解决冲突?")
- 清除缓存
就我而言,只需将扩展顺序添加到"depends"功能中即可:
In my case, a simply add extension order into the "depends" capability:
<depends>
<Mage_Catalog />
<Trego_Ajaxfilter />
</depends>
如何解决冲突? 您有3种解决冲突的选择:
- 将代码从一个有冲突的文件合并到另一个文件中,然后关闭其中的重写config.xml
- 关闭一个config.xml中的重写,然后使冲突的扩展PHP文件扩展另一个扩展
- 使用该功能使一个扩展依赖于另一个.然后,他们将按照该顺序重写
更多信息: http://www.webshopapps.com/blog/2010/11/resolving-magento-extension-conflicts/
这篇关于Magento-模型重写在本地代码中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!