3
votes

I'm trying to override in the local folder a module which is in the local folder also, but I don't know if it's possible. This is what I've done.

I've created /local/Mycompany/Modulename/Model/Model.php which i'd like to override the /local/Othercompany/Modulename/Model/Model.php

my model.php is:

class Mycompany_Modulename_Model_Model extends Othercompany_Modulename_Model_Model 

{ ... }

and my config.xml

<global>
<models>
    <othercompanymodulename>
    <rewrite>
        <model>Mycompany_Modulename_Model_Model</model>
    </rewrite>
    </othercompanymodulename>
</models>

The class is been instantiated whith Mage::getModel('othercompanymodulename/model')

My Mycompany_Mymodule.xml

<config>
<modules>
    <Mycompany_Modulename>
        <active>true</active>
        <codePool>local</codePool>
    <depend>
        <Othercompany_Modulename/>
        </depend>
    </Mycompany_Modulename>
</modules>

But my module is ignored. Is possible to override in local folder a class located also in local folder? What I'm doing wrong?

3

3 Answers

6
votes

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

1
votes

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>
0
votes

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