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
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityMagento 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.
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.
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.
<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
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
tested on Magento ver. 1.9.0.1
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:
I hope that works for some folks.