2

I want to change the sort order of the customer account sidebar navigation links and rename the texts, please help me to get the output for this situation.

Current Order & Text's:

enter image description here

Change to :

enter image description here

Note : Account Inforamtion text is changed to Update Account Information

I change code in Magento_Customer > Layout > customer_account.xml

My code :

<body>
    <move element="customer-account-navigation-orders-link" destination="customer_account_navigation" after="customer-account-navigation-address-link" />

    <!-- Remove Account Dashboard-->
    <referenceBlock name="customer-account-navigation-account-link" remove="true"/>

    <!-- Remove My Downloadable Products-->
    <referenceBlock name="customer-account-navigation-downloadable-products-link" remove="true"/>

    <!-- Remove Newsletter Subscriptions-->
    <referenceBlock name="customer-account-navigation-newsletter-subscriptions-link" remove="true"/>

    <!-- Remove My Credit Cards-->
    <referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>

    <!-- Remove Billing Agreements-->
    <referenceBlock name="customer-account-navigation-billing-agreements-link" remove="true"/>

    <!-- Remove My Product Reviews-->
    <referenceBlock name="customer-account-navigation-product-reviews-link" remove="true"/>

    <!-- Remove My Wish List-->
    <referenceBlock name="customer-account-navigation-wish-list-link" remove="true"/>
</body>

The moving element is not working in this code other removing are removed in it.

3
  • you can do by changing sort order
    – Ronak
    Commented Feb 28, 2020 at 7:27
  • 1
    Can you explain or give any example bro
    – Sabareesh
    Commented Feb 28, 2020 at 7:27
  • Check my answer. Commented Feb 28, 2020 at 9:09

2 Answers 2

1

Add the below code in your theme files

app/design/frontend/Vendor/Theme/Magento_Sales/layout/customer_account.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer_account_navigation">
            <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-orders-link">
                <arguments>
                    <argument name="path" xsi:type="string">sales/order/history</argument>
                    <argument name="label" xsi:type="string" translate="true">View All Orders</argument>
                    <argument name="sortOrder" xsi:type="number">480</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

app/design/frontend/Vendor/Theme/Magento_Customer/layout/customer_account.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page layout="2columns-left" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="sidebar.main">
            <block class="Magento\Framework\View\Element\Template" name="customer_account_navigation_block" template="Magento_Theme::html/collapsible.phtml" before="-">
                <arguments>
                    <argument name="block_title" translate="true" xsi:type="string">My Account</argument>
                    <argument name="block_css" xsi:type="string">block-collapsible-nav</argument>
                </arguments>
                <block class="Magento\Customer\Block\Account\Navigation" name="customer_account_navigation" before="-">
                    <arguments>
                        <argument name="css_class" xsi:type="string">nav items</argument>
                    </arguments>
                    <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-account-edit-link">
                        <arguments>
                            <argument name="label" xsi:type="string" translate="true">Update Account Information</argument>
                            <argument name="path" xsi:type="string">customer/account/edit</argument>
                            <argument name="sortOrder" xsi:type="number">500</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-address-link">
                        <arguments>
                            <argument name="label" xsi:type="string" translate="true">Address Book</argument>
                            <argument name="path" xsi:type="string">customer/address</argument>
                            <argument name="sortOrder" xsi:type="number">490</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Customer\Block\Account\Delimiter" name="customer-account-navigation-delimiter-2"
                           template="Magento_Customer::account/navigation-delimiter.phtml">
                        <arguments>
                            <argument name="sortOrder" xsi:type="number">470</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-account-link">
                        <arguments>
                            <argument name="label" xsi:type="string" translate="true">My Account</argument>
                            <argument name="path" xsi:type="string">customer/account</argument>
                            <argument name="sortOrder" xsi:type="number">250</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Customer\Block\Account\Delimiter" name="customer-account-navigation-delimiter-1"
                           template="Magento_Customer::account/navigation-delimiter.phtml">
                        <arguments>
                            <argument name="sortOrder" xsi:type="number">200</argument>
                        </arguments>
                    </block>
                </block>
            </block>
        </referenceContainer>
        <move element="page.main.title" destination="content.top" before="-"/>
    </body>
</page>

save the files and flush the cache, It works for me, Check below screenshot

enter image description here

2
  • Thank you very much @Kishore Thummar brother :-) it's worked fine.
    – Sabareesh
    Commented Feb 28, 2020 at 9:12
  • Would just like to add (For anyone that's not looking to copy/paste) that the class of class="Magento\Customer\Block\Account\SortLinkInterface" was important here in Magento 2.4. Simply calling <referenceBlock name="..." with the argument didn't work correctly
    – Zudian
    Commented Mar 4, 2022 at 18:24
1

For Magento 2.4+ the "Magento\Customer\Block\Account\SortLinkInterface" class needs to be used, instead of "Magento\Framework\View\Element\Html\Link\Current"

I was trying to add a new link to the customer account dropdown menu in top.links using the "Magento\Framework\View\Element\Html\Link\Current" class and a "sortOrder" argument. This added my new link, but the sorting didn't apply. Then I switched to using the SortLinkInterface and the link was added with the correct sort order:

    <referenceBlock name="top.links">
        <block class="Magento\Customer\Block\Account\SortLinkInterface" name="add-new-link" after="my-account-link">
            <arguments>
                <argument name="path" xsi:type="string">sales/order/history</argument>
                <argument name="label" xsi:type="string" translate="true">My Orders</argument>
                <argument name="sortOrder" xsi:type="number">50</argument>
            </arguments>
        </block>
    </referenceBlock>

Your Answer

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

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