Managing navigation links in the account dashboard

In this article I’ll demonstrate how to manage navigation links in the customer’s account dashboard: one way of removing new links from customer’s account dashboard which should be avoided and another way which is the way to go.
One approach to delete desired links would be to comment out the action that displays the link. As an example I’ll take “Account Information” link in account dashboard which is located in app/design/frontend/base/default/layout/customer.xml (line 230).
<action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
However, editing core files in Magento is never a good idea. Instead of this approach we’ll use something different.
For start we’ll have to edit our config.xml file, we have to rewrite Magento’s core file.
<global>
<blocks>
<customer>
<rewrite>
<account_navigation>Inchoo_Core_Block_Customer_Account_Navigation</account_navigation>
</rewrite>
</customer>
</blocks>
</global>
Next we have to define our layout xml file:
<frontend>
<layout>
<updates>
<inchoo_core>
<file>inchoo_core.xml</file>
</inchoo_core>
</updates>
</layout>
</frontend>
Next step would be to create Block/Customer/Account/Navigation.php with following class:
class Inchoo_Core_Block_Customer_Account_Navigation extends Mage_Customer_Block_Account_Navigation
{
public function removeLinkByName($name) {
unset($this->_links[$name]);
}
}
Last thing we need to do is create layout xml file in app/design/frontend/default/default/layout/inchoo_core.xml:
<?xml version="1.0" ?>
<layout version="0.1.0">
<customer_account translate="label">
<reference name="customer_account_navigation">
<action method="removeLinkByName"><name>billing_agreements</name></action>
<action method="removeLinkByName"><name>recurring_profiles</name></action>
<action method="removeLinkByName"><name>tags</name></action>
<action method="removeLinkByName"><name>wishlist</name></action>
<action method="removeLinkByName"><name>OAuth Customer Tokens</name></action>
<action method="removeLinkByName"><name>downloadable_products</name></action>
</reference>
</customer_account>
</layout>
Now for every link we want to remove from navigation we need to add navigation link name and write the name of that link inside name tag.
This is a list of all names for navigation links in account dashboard (in default order of their appearance):
- account
- account_edit
- address_book
- orders
- billing_agreements
- recurring_profiles
- reviews
- tags
- wishlist
- OAuth Customer Tokens
- newsletter
- downloadable_products
Adding new links to the navigation is even easier then removing them. All we need to do is add this code to our layout xml file:
<?xml version="1.0" ?>
<layout version="0.1.0">
<customer_account translate="label">
<reference name="customer_account_navigation">
<action method="addLink"><name>test checkout</name><path>checkout</path><label>Inchoo Checkout</label></action>
</reference>
</customer_account>
</layout>
End result should be like this
18 comments
In your post I missed the way on adding the link ‘Delete My Account’.
How can I achieve this?
Your tutorial starts good when mentioning that it is never a good idea to edit Magento core files, but immediately after that it becomes very vague and sloppy! Can you please stick to a typical step-by-step tutorial explaining where to create what and how? Only the last step (Last thing we need to do is create layout xml file in app/design/frontend/default/default/layout/inchoo_core.xml:) was in detail.
Here is what I mean:
For start we’ll have to edit our config.xml file, we have to rewrite Magento’s core file. where? how?
Next we have to define our layout xml file: where?
Next step would be to create Block/Customer/Account/Navigation.php with following class: please specify a more detailed path?
Thank you
hello
I want o change the links for my submenu, I WANT WHEN I CLIck on collections i see my collections for each category
Can you help me how to add Log Out link at the end?
Hi,
I need to add one extra field say measurment in my left my account navigation and there will be fields to save customer details.
Can anyone help me to make this happen? Any help will be appreciated.
Thank you.
Regards
Tinku
Email: tinku@madspark.in
Hi, i always use this module in my projects. that’s very useful. I would like to install it with composer. Are there a repository? can i sent you a pull request or can I fork the module? tnx! Irene
by Using magento layout xml files you can add/remove custom menu items. for more detail and code go to http://magentomonsters.com/how-to-addremove-links-on-my-account-navigation/
The linked code is incomplete and nowhere as detailed as this tutorial.
Hii Sola, Good post
how to change the label name for example I need to change “Account Dashboard” to “Dashbord”. How it posiible..?
Please help me .. please mail the solution
Thanking you in advance
hi sibin,
open this file :
app\design\frontend\base\default\template\customer\account\dashboard.phtml or
app\design\frontend\[yourtheme]\default\template\customer\account\dashboard.phtml
find this :
__(‘Account Dashboard’) ?>
(mine line 29)
you can change Account Dashboard to Dashboard
How to set order for my custom link
hi Yagnesh, try this tutorial : http://stackoverflow.com/questions/18615647/change-the-order-of-navigation-in-my-account-page-in-magento and http://magento.stackexchange.com/questions/25700/how-to-change-magento-my-account-links-order
H all,
Is there any chance to dispaly link based on customer group?
please reply..!
Are you sure this is the right way to achieve this? I do not. Why we need to override/extend Magento’s blocks when we can use event-observer architecture to get the same result without touching any core class or conflicting with any third party module which also uses it (even it is bad)?
I would also add there isset() test before unsetting that – just in case
This functionality was added to the core during the recent Hackathon in Zurich and will be available with next Magento release (which will most likely happen at Imagine).
https://github.com/magento/bugathon_march_2013/blob/master/app/code/core/Mage/Customer/Block/Account/Navigation.php
Thanks for sharing.
BTW, you can also find this feature available on community extension called ‘Frontend Links Manager’:
http://www.magentocommerce.com/magento-connect/frontend-links-manager.html
Even you can turn off the footer/top links easily from system configuration.
Happy E-Commerce!
A while ago we made an OpenSource module that does the same 🙂
https://github.com/netz98/N98_LayoutHelper