Overriding Third Party Extension Modules Model Not Working in Magento

extensionsmodeloverrides

I've created a small module

app/code/local/Mycompany/Managa/config.xml

  <?xml version="1.0" encoding="UTF-8"?>

<config> 

<modules>
    <Mycompany_Managa>
        <version>0.1.0</version>
    </Mycompany_Managa>
</modules>

<global>
    <models>
        <mana_filters>
            <rewrite>
                   <managa>Mycompany_Managa_Filters_Model_Filter_Attribute</managa>
            </rewrite>
        </mana_filters>
    </models>
</global>

</config>

app/code/local/Mycompany/Managa/Filters/Model/Filter/Attribute.php

  class Mycompany_Managa_Filters_Model_Filter_Attribute extends Mana_Filters_Model_Filter_Attribute
{
  //exact copy of Mana_Filters_Model_Filter_Attribute
 }

app/etc/modules/Mycompany_Managa.xml

  <?xml version="1.0" encoding="UTF-8"?>
 <config>
 <modules>
    <Mycompany_Managa>

        <active>true</active>

        <codePool>local</codePool>

        <depends>
            <Mana_Filters/>
        </depends>

    </Mycompany_Managa>
</modules>


</config>

The file that I'm trying to override is located at /app/code/local/Mana/Filters/Model/Filter/Attribute.php and as mentioned above it has a class – Mana_Filters_Model_Filter_Attribute.

I assume it's something to do with my config file but no matter what I do I can't seem to get the site to use my version of the model. I've followed other questions with similar questions such as – one,two and three, but I'm obviously doing something wrong.

Best Answer

there are lot of issue on you code

1. Folder Structure ISSUE:

There are only two folder Upto Model folder:

Need change folder stucture

From:

Mycompany/Managa/Filters/Model/Filter/Attribute.php

TO:

Mycompany/Managa/Model/Filter/Attribute.php

Need to change at Class name accordingly:

Mycompany_Managa_Filters_Model_Filter_Attribute

TO

Mycompany_Managa_Model_Filter_Attribute

2.Third Party Model Prefix issue:

You need to checked first Mana_Filters Model prefix:

in Mana_Filters Config.xml check models prefix.

  <models>
    <model_prefix> <!-- This is call  Model Prefix -->
        <class>Mana_Filters</class>
    </model_prefix> <!-- This is call  Model Prefix -->
    </models>

Config.xml

<global>
    <models>
        <mana_filters> <!-- Check  Manadev Filter Prefix -->
            <rewrite>
                   <filter_attribute>Mycompany_Managa_Model_Filter_Attribute</filter_attribute>
            </rewrite>
        </mana_filters>
    </models>
</global>
Related Topic