Every Magento client we’ve worked with, has unique needs and requirements for the customers that use their site. Magento has a big and expansive library of features to fit many of our merchant’s needs but that doesn’t mean that retailers need to execute every feature available in order to provide great customer experience. If we kept all the unnecessary features enabled, it could create a frustrating experience for site users as some features might not do anything. One great example is the customer account navigation menu.
That link is added with this layout XML declaration in app/design/frontend/base/default/layout/sales/recurring_profile.xml:
|<reference name="customer_account_navigation" >|
|<action method="addLink" translate="label">|
This is quite fine as usually there are remove versions of the methods to add things through XML, but when inspecting the block element in use for adding that link (Mage_Customer_Block_Account_Navigation), there is no opposing removeLink for the addLink method. This is where we’re going to start doing our work.
#1. House Our Rewrite in a Module
First things first, we need to house our rewrite in a module. If you have a preexisting module you want to add this to, you can skip creating the app/etc/modules/Acme_Module.xml file.
Create app/etc/modules/Acme_Module.xml. This will tell Magento about our new Module that houses our rewritten class.
#2. Create our app/code/local/Acme/Module/etc/config.xml
By creating our app/code/local/Acme/Module/etc/config.xml, this file will tell Magento where to find our rewritten class.
#3. Install app/code/local/Acme/Module/Block/Account/Navigation.php
Now, for our class that adds our layout XML method. Install this in app/code/local/Acme/Module/Block/Account/Navigation.php:
#4. REMOVE LINK WITH LOCAL.XML
After that’s all done, we can add this to our local.xml:
The name argument can be determined by finding the name as described in the original XML files where addLink was called.
That’s all folks!