+91 796-525-5075 ( 11AM To 7PM-IST )

Overriding Helper In Magento

Some time we developers need to add new functionality of existing Magento core helper classes, but we can’t modify core classes, because if we upgrade magento in future time then our changes will gone away.So better to avoid changing the core files.

Suppose we have a module called Lr_Custom present at local directory app/code/local/Lr/Custom and we want rewrite below model classes

Overriding Helper:

Suppose we want to rewrite the method resize of class Mage_Catalog_Helper_Image,then we need these below files

  • app/etc/modules/Lr_Custom.xml : It’s a file used to enable our custom module.
  • app/code/local/Lr/Custom/etc/config.xml: It’s a module configuration file in which we’ll set up helper class overriding using certain tags as per the Magento conventions.
  • app/code/local/Lr/Custom/helper/catalog/Image.php : It’s a custom helper class file which we’ll use to override the core “Catalog” helper class.

and we can rewrite by below code in confi.xml file.


we can divide the class Mage_Catalog_Helper_Image into different parts like

  • Mage_Catalog_Helper
  • Image

here we got “Mage_Catalog_Helper” by “catalog“, and for whole class “Mage_Catalog_Helper_Image” by “catalog/image

finally your file will be at Lr_Custom_Helper_Catalog_Image means

class destination would be

Finally our module files will be

dir: app/etc/modules/Lr_Custom.xml

dir: app/code/local/Lr/Custom/etc/config.xml

Rewrite Class: