开发者

Magento: Unable to override Sales Rule

开发者 https://www.devze.com 2023-04-12 00:15 出处:网络
I am unable to override Sales Rule Model. I want to override class Mage_SalesRule_Model_Rule. Here is my code:-

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"?>
<conf开发者_如何学Pythonig>
    <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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号