Magento: Overriding Helpers

You can override helper in Magento in following way.
Steps to Override helper in Magento:
1) When we override the helper in the module, we should not change the core helper files directly. To do this, we add following xml in config.xml inside the our custom module:
<helpers>
<customer>
<rewrite>
<data>Mynamespace_Test_Helper_Data</data>
</rewrite>
</customer>
</helpers>

2) We create a new custom class in our helper folder at path app/code/local/Mynamespace/Test/Helper/Data.php in our custom module.

<?php
class Mynamespace_Test_Helper_Data extends Mage_Customer_Helper_Data
{
}
Thats's it! You have overrided the core helper 'Mage_Customer_Helper_Data'.

Note: We can only override the classes for which objects can be created. We can not override the abstract classes for which no object is created.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s