1

I want to overwrite the class Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection. But my new classes is ignored at the frontend. Any idea how to fix that? Is my config.xml wrong? Cache renewed several times.

Magic_Base.xml ( app/etc/modules )

<config>
    <modules>
        <Magic_Base>
            <active>true</active>
            <codepool>local</codepool>
        </Magic_Base>
    </modules>
</config>

/app/code/local/Magic/Base/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php ( which is the overwritten class )

Magic_Base_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection
    extends Mage_Core_Model_Resource_Db_Collection_Abstract

config.xml ( Magic/Base/etc/config.xml )

 <config>
    <modules>
        <Magic_Base>
            <version>0.1</version>
        </Magic_Base>
    </modules>
    <global>
       <models>
          <catalog>
              <rewrite>
                  <resource_product_type_configurable_attribute_collection>Magic_Base_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection</resource_product_type_configurable_attribute_collection>
              </rewrite>
          </catalog>


           <catalog_resource_product_type_configurable_attribute>
              <rewrite>
                  <collection>Magic_Base_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection</collection>
              </rewrite>
          </catalog_resource_product_type_configurable_attribute>

       </models>
    </global>
</config>
1

You're not rewriting the class properly in your config.xml, it should be like this:

<config>
    <modules>
        <Magic_Base>
            <version>0.1</version>
        </Magic_Base>
    </modules>
    <global>
       <models>  
           <catalog_resource>
              <rewrite>
                  <product_type_configurable_attribute_collection>Magic_Base_Model_Catalog_Resource_Product_Type_Configurable_Attribute_Collection</product_type_configurable_attribute_collection>
              </rewrite>
          </catalog_resource>

       </models>
    </global>
</config>
1

You have done lot of mistake

  • Magic_Base.xml does not define properly

In this xml file codepool should codePool .P should upper case.

<?xml version="1.0" encoding="utf-8"?>
<config>
    <modules>
        <Magic_Base>
            <active>true</active>
            <codePool>local</codePool> <!-- p should be UpperCase P -->
        </Magic_Base>
    </modules>
</config>
  • Rewrite code is wrong in config.xml

As you have rewrite resource class then you could not rewrite like this code:

  <catalog>
              <rewrite>
                  <resource_product_type_configurable_attribute_collection>Magic_Base_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection</resource_product_type_configurable_attribute_collection>
              </rewrite>
          </catalog>


           <catalog_resource_product_type_configurable_attribute>
              <rewrite>
                  <collection>Magic_Base_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection</collection>
              </rewrite>
          </catalog_resource_product_type_configurable_attribute>

it should be catalog from catalog_resource.

As per as ,magento catalog_resource resource type class is Mage_Catalog_Model_Resource

See at config.xml of Mage_Catalog

So config.xml code should be

<?xml version="1.0" encoding="utf-8"?>
<config>
  <modules>
    <Magic_Base>
      <version>0.1.0</version>
    </Magic_Base>
  </modules>
  <global>
    <models>
            <catalog_resource> <!-- change here -->
                <rewrite>
                <product_type_configurable_attribute_collection>Magic_Base_Model_Catalog_Resource_Product_Type_Configurable_Attribute_Collection</product_type_configurable_attribute_collection>
                </rewrite>
            </catalog_resource>
    </models>
  </global>
</config>
  • File location:

    Should be from

app/code/local/Magic/Base/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php

to

app/code/local/Magic/Base/Model/Catalog/Resource/Product/Type/Configurable/Attribute/Collection.php

Also need to class name:

<?php
class Magic_Base_Model_Catalog_Resource_Product_Type_Configurable_Attribute_Collection extends Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection
{
}
  • Thank you very much, I like the flexibility of Magento - but sometimes this is really painful. The same issue again, located in /app/code/local/Magic/Base/Model/Eav/Entity/Attribute/Frontend class Magic_Base_Model_Eav_Entity_Attribute_Frontend_Default config.xml snippet ... <models> <eav_entity> <rewrite> <attribute_frontend_default>Magic_Base_Model_Eav_Entity_Attribute_Frontend_Default</attribute_frontend_default> </rewrite> </eav_entity> </models> – Christian Feb 16 '16 at 10:49
  • flexibility of Magento , is not my hand, You need to follow magento process.Please accept this answer. – Amit Bera Feb 16 '16 at 17:34
0

Thank you very much, I like the flexibility of Magento - but sometimes this is really painful.

The same issue again, located in /app/code/local/Magic/Base/Model/Eav/Entity/Attribute/Frontend

class Magic_Base_Model_Eav_Entity_Attribute_Frontend_Default

config.xml snippet

    ...
    <models>
    <eav_entity>
      <rewrite> 

<attribute_frontend_default>Magic_Base_Model_Eav_Entity_Attribute_Frontend_Default</attribute_frontend_default>
    </rewrite>
    </eav_entity>
    </models>

It does not work. Is there any way to debug this - so that I see what magentos tries to open/call ?!

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.