Magento:无法覆盖销售规则 [英] Magento: Unable to override Sales Rule

查看:72
本文介绍了Magento:无法覆盖销售规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法覆盖销售规则模型.我想覆盖类 Mage_SalesRule_Model_Rule .

I am unable to override Sales Rule Model. I want to override class 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>

但这是行不通的.

请帮忙吗?

推荐答案

谢谢大家帮助调试我的问题.

Thank you all for helping in debugging my problem.

问题已经解决.

我也已经在另一个本地模块XML文件中编写了覆盖代码.但是,我已经评论了该代码,并且我的缓存被禁用了.但是,我不知道它是怎么引起问题的.因此,当我从另一个模块中删除了注释的代码时,我的问题就解决了,并且能够覆盖salesrule模型.

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.

  • 重新检查您的XML代码段是否位于正确的位置.
  • 检查模块是否正在实例化(系统->配置->高级).
  • 检查其他可能也覆盖相同模型的模块.尤其是本地"用户,因为它们具有优先权.
  • 检查在调用所需班级时返回的班级:

  • 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'));

谢谢大家的评论.

这篇关于Magento:无法覆盖销售规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆