Magento Core Helper – How to Rewrite Mage::helper(‘core’) Class

classcorehelperoverrides

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?

Best Answer

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.