0
votes

I tried to re declare a core module model class(Mage_Catalog_Model_Product). I created a test module and named it First_Module also I created a config.xml file in it:

<?xml version="1.0"?>
<config>
   <default>
       <models>
           <catalog>
               <rewrite>
                   <product>First_Module_Model_Product</product>
               </rewrite>
           </catalog>
        </models>
   </default>
</config>

Then I created app/code/local/First/Module/Model/Product.php and delaclared a class in it: class First_Module_Model_Product extends Mage_Catalog_Model_Product.

Link to image of directory structure: http://i58.tinypic.com/abqetz.png

Also I created the First_Module.xml file in app/etc/modules:

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

Then I tried to run test but it not working:

Zend_Debug::dump( Mage::getStoreConfig('global/models/catalog') ) -> 
array(1) {
  ["rewrite"] => array(1) {
    ["product"] => string(26) "First_Module_Model_Product"
  }
}

$model = Mage::getModel('catalog/product');
Zend_Debug::dump(get_class($model)); // prints Mage_Catalog_Model_Product, but I wont to see First_Module_Model_Product.

Where I'm wrong?

1

1 Answers

0
votes

Add your models rewrite information in <global> tag instead of <default> tag

 <global>
   <models>
       <catalog>
           <rewrite>
               <product>First_Module_Model_Product</product>
           </rewrite>
       </catalog>
    </models>
</global>