Remove customer account navigation links in Magento

Magento Logo

Sometimes you may want to remove certain navigation items in Magento’s built-in customer account navigation pane, such as “Recurring Profiles” or “My Applications” (OAuth). Fortunately, due to Magento’s underlying software architecture this can be achieved rather easily by disabling/removing the respective layout blocks.

Since the primary goal should be to create a solution that can be re-used for other systems and Magento versions the best option here is to write a simple Magento module that in addition can be controlled with your system’s local.xml. Thus, in order to be able to configure these navigation items in the customer account we need a module that adds functionality to actually removeLinkByName in local.xml, by redirecting requests to the original controller (Mage_Customer_Block_Account_Navigation) to a custom controller (KerstnerAt_FilterCustomerAccountNavigation_Block_Account_Navigation) which in turn unsets the corresponding layout blocks.

The Magento Module

First we need to setup the module: app/etc/modules/KerstnerAt_FilterCustomerAccountNavigation.xml:

<config>
  <modules>
    <KerstnerAt_FilterCustomerAccountNavigation>
      <version>1.0.0</version>
      <active>true</active>
      <codePool>local</codePool>
    </KerstnerAt_FilterCustomerAccountNavigation>
  </modules>
</config>

Followed by the module’s config.xml: app/local/KerstnerAt/FilterCustomerAccountNavigation/etc/config.xml:

<config>
  <global>
    <blocks>
      <customer>
        <rewrite> 
          <account_navigation>KerstnerAt_FilterCustomerAccountNavigation_Block_Account_Navigation</account_navigation>
        </rewrite>
      </customer>
    </blocks>
  </global>
</config>

Finally, our custom controller that actually removes the navigation items in the customer account by “un-setting” the corresponding layout blocks specified in local.xml: app/local/KerstnerAt/FilterCustomerAccountNavigation/Block/Account/Navigation.php:

class KerstnerAt_FilterCustomerAccountNavigation_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation {
  public function removeLinkByName($name) {
    unset($this->_links[$name]);
  }
}

Using local.xml to remove navigation items

As always, use local.xml to set configuration options for this custom module by specifying the blocks name. Here, we remove the “My Applications” and “Recurring Profiles” items:

<customer_account translate="label">
  ...
  <reference name="customer_account_navigation">
    <action method="removeLinkByName">
      <name>OAuth Customer Tokens</name>
    </action>
    <action method="removeLinkByName">
      <name>recurring_profiles</name>
    </action>
  </reference>
...

List of customer account navigation items in Magento

Here’s a full list of currently supported customer account navigation links:

  • My Account: account
  • Account Edit: account_edit
  • Address Book: address_book
  • My Orders: orders
  • My Tags: tags
  • My Wishlist: wishlist
  • My Applications: OAuth Customer Tokens
  • Recurring Profiles: recurring_profiles
  • Billing Agreements: billing_agreements
  • My Downloadable Products: downloadable_products
  • My Reviews: reviews
  • My Invitations: invitations
  • Newsletter Subscriptions: newsletter
  • Logout: logout

Additional (enterprise) links in customer account:

  • Customer Account Balance: enterprise_customerbalance
  • Giftcard Account: enterprise_giftcardaccount
  • Gift Registry: giftregistry
  • Reward Points: enterprise_reward

This module was tested with Magento 1.8 and higher. I will submit this module on Magento Connect too.

Comments

One response to “Remove customer account navigation links in Magento”

  1. Michael Avatar
    Michael

    Working perfectly! Thank you so much for this!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.