1

I need to override Mage_Tag_Model_Resource_Tag_Relation for a site I'm working on.

I have already created my class that extends Mage_Tag_Model_Resource_Tag_Relation:

class Web_Core_Model_Tag_Resource_Tag_Relation extends Mage_Tag_Model_Resource_Tag_Relation
{
    public function loadByTagCustomer($model)
    {
    [...]
    }
}

And placed that in the file app/code/local/Web/Core/Model/Tag/Resource/Tag/Relation.php

In the module's config.xml (which is activated, since there are other parts of the module that are working, I added:

<global>
  <models>
    <core>
      <rewrite>
       <mage_tag_model_resource_tag_relation>
        Web_Core_Model_Tag_Resource_Tag_Relation
       </mage_tag_model_resource_tag_relation>
     </rewrite>
    </core>
 </models>
</global>

I'm guessing this is wrong, since it is not working... How should I declare the overriding in my config.xml? Am I in the right track?

3

You did not rewrite resource class in proper method and did not follow up magento resource model class format that why it does not override properly.

Basic format of overwrite a resource class is

   <models>
        <rewriteableModuleResourceClassIndenfiter>
            <rewrite>
                <Rest_Of_ClassName_Of_Resource_class>Your_Write_Class_Name</Rest_Of_ClassName_Of_Resource_class>
            </rewrite>
        </<rewriteableModuleResourceClassIndenfiter>
    </models>

Brief:

As per as ,magento tag_resource is resource type of magento Mage_Tage module,which prefix class is Mage_Tag_Model_Resource

See at config.xml of Mage_Tag Module

 <tag_resource>
                <class>Mage_Tag_Model_Resource</class>

You modified code:

<models>
    <tag_resource>
        <rewrite>
            <tag_relation>Web_Core_Model_Tag_Resource_Tag_Relation</tag_relation>
        </rewrite>
    </tag_resource>
</models>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.