Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Why doesnt my code overwrite the core magento code? 
 
jdholm
Jr. Member
 
Total Posts:  3
Joined:  2013-09-03
 

I am trying to overwrite Mage_Catalog_Helper_Product_Compare. In config.xml I have the following:

...
        <
helpers>
            <
catalog>
                <
rewrite>
                    <
compare>Caupo_CustomCompare_Helper_Product_Compare</compare>
                </
rewrite>
            </
catalog>
        </
helpers>
...
and I have a file /var/www/site/app/code/local/Caupo/CustomCompare/Helper/Product/Compare.php that contains:
<?php
class Caupo_CustomCompare_Helper_Product_Compare extends Mage_Catalog_Helper_Product_Compare {
    
public function getItemCollection() {
        Mage
::log('compare/getItemCollection');
    
}
}
?>
I also have
Mage::log('getItemCollection-test');
in /var/www/site/app/code/core/Mage/Catalog/Helper/Product/Compare.php for debuging.
When I load a magento page with the compare list I get ’getItemCollection-test‘ in system.log instead of ’compare/getItemCollection‘. What am I missing?
 
Magento Community Magento Community
Magento Community
Magento Community
 
magedev
Sr. Member
 
Avatar
Total Posts:  117
Joined:  2009-06-01
 

Your rewrite definition should say:

<helpers>
        <
catalog>
            <
rewrite>
                <
product_compare>Caupo_CustomCompare_Helper_Product_Compare</product_compare>
            </
rewrite>
        </
catalog>
</
helpers>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top