Magento: how to override a model in a local module

青春壹個敷衍的年華 提交于 2019-12-06 07:34:31

open your [magento]\app\etc\modules\Mycompany_Modulename.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_Modulename>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Othercompany_Modulename/>
            </depends>
        </Mycompany_Modulename>
    </modules>
</config> 

above code force Othercompany_Modulename to load first.

hope this help you

If i'm right you missed an underscore in the definition of the overwritten model in your config.xml:

<global>
  <models>
    <othercompany_modulename>
      <rewrite>
        <model>Mycompany_Modulename_Model_Model</model>
      </rewrite>
    </othercompany_modulename>
  </models>
</global>
kxo

It's probably an extension conflicts.

How to check and resolve:

  1. Check extension are conflicted with this free magento module: http://www.magentocommerce.com/magento-connect/modules-conflict-detector.html
  2. Locate conflicted extension and use one solution for resolve (read bottom "How do I resolve conflicts?")
  3. Clear cache

How do I resolve conflicts? You have 3 choices for resolving conflicts:

  1. Merge the code from one conflicting file into another and switch off the rewrite config.xml in one
  2. Switch off the rewrite in one config.xml and then make the conflicting extension PHP file extend the other extension
  3. Use the capability to make one extension depend on another. They will then rewrite in that order

Read more: http://www.webshopapps.com/blog/2010/11/resolving-magento-extension-conflicts/ Related: Magento - Model Override Not Working in local codePool

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