Magento: Unable to override Sales Rule

大兔子大兔子 提交于 2019-12-24 19:06:39

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/7688803/magento-unable-to-override-sales-rule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!