Overriding magento helpers

February 16, 2016
Posted by admin 1:28 PM

In magento if we have to enhance some helper classes of core files then according to  magento standard formatwe have to override that class in our own Local Module.

For that we need to create our own module and to make the chnages in local module

config.xml file, and some changes in our own module helper class.

To override the Helper classes we have to add <rewrite></rewrite> tag under module name.

 

Let us take an example that we need to override 

Mage_Checkout_Helper_Data

then below is the code we need to write in our config file under global node.

 Our own module name is Hello module and in we need to write the code at below path

 app/code/core/local/Hello/Checkout/etc/config.xml

 For overriding Mage_Checkout_Helper_Data

 <config>

       <global>

              <helpers>

                      <checkout>

                              <rewrite>

                                    <data>Hello_Checkout_Helper_Data</data>

                            </rewrite>

                   </checkout>

              </helpers>

   </global> 

</config>

 And as per the core class path we have to create the below files in our module

 app/code/core/local/Hello/Checkout/Helper/Data.php,

 In this file the code will be

 class Hello_Checkout_Helper_Data extends Mage_Checkout_Helper_Data

{

  // module code according to requirment

}

Now magento will read our helper rather than magento core helper.