2

Hi I need to change magento my account links order. Now it looks like bellow

  • Account Information
  • Address Book
  • My Orders
  • My Wishlist

I need to change the order like,

  • My Orders
  • My Wishlist
  • Account Information
  • Address Book

5 Answers 5

6

Magento core code not provide this type of works.So we need a create extension

1) In app/etc/modules/Bh_Customerlink.xml and code of this file

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

2)Create a block in app/code/local/Bh/Customerlink/Block/Customer/Account/Navigation.php & put the following code

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

**3)**Create module configuration file at app/code/local/Bh/Customerlink/etc/config.xml and code of this file in below:

<?xml version="1.0"?>
    <config>
        <modules>
            <BH_Customerlink>
                <version>0.1.0</version>
            </BH_Customerlink>
        </modules>
        <frontend>
            <layout>
                <updates>
                    <bH_customerlink>
                        <file>customerlink.xml</file>
                    </bH_customerlink>
                </updates>
            </layout>
        </frontend>

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

**4)**Replace code in app/design/frontend/default/default/layout/customerlink.xml

<?xml version="1.0" ?>
    <layout version="0.1.0">
        <customer_account translate="label">
            <reference name="customer_account_navigation">
                <action method="removeLinkByName"><name>account</name></action>
                <action method="removeLinkByName"><name>account_edit</name></action>            
                <action method="removeLinkByName"><name>address_book</name></action>
                <action method="removeLinkByName"><name>reviews</name></action>
                <action method="removeLinkByName"><name>orders</name></action>
                <action method="removeLinkByName"><name>newsletter</name></action>
                <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>
        <customer_account translate="label">
            <reference name="customer_account_navigation">
                <action method="addLink"><name>orders</name><path>sales/order/history/</path><label>My Order</label></action>
                <action method="addLink"><name>wishlist</name><path>wishlist/</path><label>My Wishlist</label></action>
                <action method="addLink"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
                <action method="addLink"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>        
                <action method="addLink"><name>billing_agreements</name><path>sales/billing_agreement/</path><label>Billing Agreements</label></action>
                <action method="addLink"><name>recurring_profiles</name><path>sales/recurring_profile/</path><label>Recurring Profiles</label></action>
                <action method="addLink"><name>reviews</name><path>review/customer/</path><label>My Product Reviews</label></action>
                <action method="addLink"><name>tags</name><path>tag/customer/</path><label>My Tags</label></action>
                <action method="addLink"><name>address_book</name><path>oauth/customer_token/</path><label>My Applications</label></action>
                <action method="addLink"><name>OAuth Customer Tokens</name><path>newsletter/manage/</path><label>Newsletter Subscriptions</label></action>
                <action method="addLink"><name>downloadable_products</name><path>downloadable/customer/products/</path><label>My Downloadable Products</label></action>


            </reference>
        </customer_account>

    </layout>

Now you can add/remove or re-arrange customer links. I hope it will be help you.

4
  • Thanks for the effort :-).I am not have any file named Bh_Customerlinl.xml. But I can create a custom module with same name. Before going to create a custom module can you please explain me how this changes will work. Because the code not seems ok for my question... Is it reorder my account links? Jul 2, 2014 at 7:34
  • The above code, You can remove/add any link from customer account left navigation. Other words, You can re-arrange the default customer account left navigation links. Jul 2, 2014 at 7:41
  • Thanks, your updated answer help me to do the changes. I have removed <reference name="customer_account_navigation"> from the sales.xml and added <action method="addLink" translate="label" module="sales"><name>orders</name><path>sales/order/history/</path><label>Orders</label></action> into the customer.xml. same for wishlist. So now I got what I want. Thanks for your help. Please remove your custom code,and keep it ur updated code. I will accept it as a answer. Jul 2, 2014 at 8:00
  • Update my layout xml. plesse see. Jul 2, 2014 at 8:43
2

By default Magento addLink() function for customer account section (which is under: app/code/core/Mage/Customer/Block/Account/Navigation.php) only takes 4 parameters, i.e.

  • name
  • path
  • label
  • urlParams = array()

It does not take position of links. If you want to set position from layout xml files, then you need to first override Navigation.php block file and change method addLink() to have parameter for position also. Then you can set position parameter position in layout xml files.

I hope you will get my point from above solution. If you have any question, then please feel free to post here.

1
<reference name="left">
            <block type="customer/account_navigation" name="customer_account_navigation" after="-" template="customer/account/navigation.phtml">
                <action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
                <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
                <action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
            </block>
</reference>

In customer links and remove extra tab and use before with order and wishlist links from xml

1

you do not need to create a new module.just add this code to your local.xml

<customer_account>
    <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
        <action method="addLink" translate="label" module="sales"><name>orders</name><path>sales/order/history/</path><label>My Orders</label></action> 
        <action method="addLink" translate="label" module="wishlist" ifconfig="wishlist/general/active"><name>wishlist</name><path>wishlist/</path><label>My Wishlist</label></action>
        <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Informations</label></action>
        <action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
    </block>
</customer_account>

here example image here example image

tested on Magento ver. 1.9.0.1

0

It's possible to do this without a module, and without any XML, hooray! Someone might say this is a bit non-Magento "hacky", but it's pure PHP.

The customer account navigation is assembled in a file located at app/design/frontend/base/default/template/customer/account/navigation.phtml; If you intend to use this method, do not modify the original file, instead copy that file to your own theme and modify it there.

File: app/design/frontend/theme/path/template/customer/account/navigation.phtml:

<div class="block block-account">
    <div class="block-title">
        <strong><span><?php echo $this->__('My Account'); ?></span></strong>
    </div>
    <div class="block-content">
        <ul id="account-nav">
            <?php $_links = $this->getLinks(); ?>
            <?php $_index = 1; ?>
            <?php $_count = count($_links); ?>
            <?php 
                if ( $_count ) {
                    // unset($_links['account']); /* Account Info */
                    // unset($_links['account_edit']); /* Account Info */
                    unset($_links['tags']); /* My Tags */
                    unset($_links['invitations']); /* My Invitations */
                    unset($_links['reviews']);  /* Reviews */
                    unset($_links['wishlist']); /* Wishlist */
                    // unset($_links['newsletter']); /* Newsletter */
                    // unset($_links['orders']); /* My Orders */
                    // unset($_links['address_book']); /* Address */
                    unset($_links['enterprise_customerbalance']); /* Store Credit */
                    unset($_links['OAuth Customer Tokens']); /* My Applications */
                    unset($_links['enterprise_reward']); /* Reward Points */
                    unset($_links['giftregistry']); /* Gift Registry */
                    unset($_links['downloadable_products']); /* My Downloadable Products */
                    unset($_links['recurring_profiles']); /* Recurring Profiles */
                    unset($_links['billing_agreements']); /* Billing Agreements */
                    unset($_links['enterprise_giftcardaccount']); /* Gift Card Link */
                }

                $_linkOrder = array('account', 'account_edit', 'orders', 'address_book', 'newsletter');
                $_orderedLinks = array();

                foreach ( $_linkOrder as $index ) {
                    $_orderedLinks[$index] = $_links[$index];
                }
            ?>

            <?php foreach ($_orderedLinks as $_link): ?>
                <?php $_last = ($_index++ >= $_count); ?>
                <?php if ($this->isActive($_link)): ?>
                    <li class="current<?php echo ($_last ? ' last' : '') ?>"><strong><?php echo $_link->getLabel() ?></strong></li>
                <?php else: ?>
                    <li<?php echo ($_last ? ' class="last"' : '') ?>><a href="<?php echo $_link->getUrl() ?>"><?php echo $_link->getLabel() ?></a></li>
                <?php endif; ?>
            <?php endforeach; ?>
        </ul>
    </div>
</div>

What's happening here:

First we unset (delete from the $_links array) those items we don't want. I've put all the default options in for convenience, just comment out the links you want to keep.

Next we create a new array to sort by, sort the $_links array against that one, and we are done.

I personally prefer this method because:

  • This encompasses links order, and item customisation.
  • It is all in one place.
  • No XML!
  • Uses pure PHP.
  • I'm convinced it renders faster than the XML route.

I hope that works for some folks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.