3

i want rewrite magento helper core class Mage_Core_Helper_Data. I have try below code, but it is not working

<?xml version="1.0" ?>
<config>
    <global>
            ...
        <helpers>
            <csscompresser>
                <class>Amit_CssCompresser_Helper</class>
            </csscompresser>
            <core>
                <rewrite>
                    <data>Amit_CssCompresser_Helper_Core_Data</data>
                </rewrite>
            </core>
        </helpers>
        ...
    </global>
<config>

Can any one tell why is not working?

  • can any one tell why i got down vote on this question – Amit Bera Jan 16 '15 at 12:27
9

When you rewrite a helper class, it will only take effect when you use Mage::helper('...').

However, most helper classes extend from Mage_Core_Helper_Data directly and then, the original class is used :(

For example:

class My_Custom_Helper_Class extends Mage_Core_Helper_Data {
}

If you want to rewrite such a class in all cases, you can use the ugly method to copy it into app/code/local/Mage/Core/Helper/Data.php and do your edits there.

It is not nice style, but if you want to extend a class very high up in the hierarchy, you have no other choice as far as I know.

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