Category Archives: Helper Override

Magento Helper override rules

Sometimes Magento uses helper class to retrieve some of the help info such url, name, group etc. So you have to override helper class when you want to change any url or something else. Helper class override  is similar to block and model override. Here i described details about helper override with example.  Here i show how to override helper class Mage_Customer_Helper_Data.

1. At first create new module to process override work and write below code in app/etc/modules/M4U_Customer.xml

<?xml version="1.0"?>
       <config>
             <modules>
                  <M4U_Customer>
                       <active>true</active>
                       <codePool>local</codePool>
                  </M4U_Customer>
            </modules>
     </config>

2. Do configuration in app/code/local/M4U/Customer/etc/config.xml

<?xml version="1.0"?>
    <config>
        <modules>
            <M4U_Customer>
                <version>0.1.0</version>
            </M4U_Customer>
        </modules>

        <global>
           <helpers>
              <customer>
                  <rewrite>
                      <data>M4U_Customer_Model_Customer</data>
                 </rewrite>
              </customer>
           </helpers>
        </global>
  </config>

3. Now write your new helper class M4U_Customer_Helper_Data and define all other override methods

class M4U_Customer_Helper_Data extends Mage_Customer_Helper_Data
{
   // override existing method
  * Retrieve customer register form post url
  public function getRegisterPostUrl()
    {
        return $this->_getUrl('customer/account/create2');
    }

    //write new function
    public function getRegisterPostUrl2()
    {
        return $this->_getUrl('customer/account/createpost');
    }
}

I think who is familiar with Magento override theory, helper override is easy for them. Just try your self. If you face any problem then just make a post. I will try to help you.