Magento:无法覆盖销售规则
我无法覆盖销售规则模型。我想覆盖Mage_SalesRule_Model_Rule类。
这是我的代码:-
<?xml version="1.0"?>
<config>
<modules>
<MyNamespace_MyModule>
<version>0.1.0</version>
</MyNamespace_MyModule>
</modules>
<global>
<models>
<salesrule>
<rewrite>
<rule>MyNamespace_MyModule_Model_Rule</rule>
</rewrite>
</salesrule>
</models>
</global>
</config>
但这不起作用。
有什么帮助吗?
I am unable to override Sales Rule Model. I want to override class Mage_SalesRule_Model_Rule.
Here is my code:-
<?xml version="1.0"?>
<config>
<modules>
<MyNamespace_MyModule>
<version>0.1.0</version>
</MyNamespace_MyModule>
</modules>
<global>
<models>
<salesrule>
<rewrite>
<rule>MyNamespace_MyModule_Model_Rule</rule>
</rewrite>
</salesrule>
</models>
</global>
</config>
But this doesn’t work.
Any help please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢大家帮助调试我的问题。
现在问题已经解决了。
我还在另一个本地模块 XML 文件中编写了覆盖代码。但是,我评论说代码和我的缓存已被禁用。但是,我不知道它是如何引起问题的。因此,当我删除注释代码(从另一个模块)时,我的问题就解决了,并且我能够覆盖 salesrule 模型。
如果其他人遇到这样的问题,我想为他们写一些提示。这些提示基于此问题中的评论。
重新检查您的 XML 代码段是否位于正确的位置。
检查模块是否正在实例化(系统 -> 配置 -> 高级)。
检查是否有其他模块也可能覆盖同一模型。尤其是那些“本地”的,因为它们优先。
检查调用所需的类时返回的类:
echo get_class(Mage::getModel('salesrule/rule'));
感谢大家的评论。
Thank you all for helping in debugging my problem.
The problem is solved now.
I had written the override code in another local module XML file as well. However, I had commented that code and my cache is disabled. But, I don't know how it was causing problem. So, when I removed that commented code (from another module) then my problem was solved and I was able to override salesrule model.
I would like to write some tips for others if they face such problem. These tips are based on the comments in this question.
Recheck if your XML snippet is in the right location.
Check if the module is being instantiated (System -> Configuration -> Advanced).
Check for other modules that may also be overriding the same model. Especially those in 'local' since they take precedence.
Check what class is returned when you call your desired class:
echo get_class(Mage::getModel('salesrule/rule'));
Thank you all for your comments.