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.

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
scroll top