2

I want to change magento 2 customer navigation sidebar menu title.

for example: Account information turns into My Profile

What I've done so far:

customer_account.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Customer My Account (All Pages)" design_abstraction="custom">
    <body>
        <referenceContainer name="sidebar.main">
            <block class="Magento\Framework\View\Element\Html\Links" name="customer_account_navigation" before="-" cacheable="false" template="Magento_Customer::account/navigation.phtml">
                <referenceBlock name="customer-account-navigation-account-link" remove="true"/>
                <referenceBlock name="customer-account-navigation-account-edit-link">
                    <arguments>
                        <argument name="label" xsi:type="string" translate="true">My Profile</argument>
                        <argument name="path" xsi:type="string">customer/account/edit</argument>
                    </arguments>
                </referenceBlock> 
            </block>
        </referenceContainer>
    </body>
</page>
3

The reason why it's not working is because it's getting overwritten in the luma theme.

If you want to change that, create a theme that extends the luma theme and change it there.

Check the file under theme-luma/Magento_Customer/layout/customer_account.xml

If you change it there it will work, but.. you don't wanna change that directly in the luma theme.. ;) so extend the theme and voilà!

Create a custom theme and activate it. Make sure it's a child of the luma theme

theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>My new super awesome fabulous theme!</title>
    <parent>Magento/luma</parent>
</theme>

then create the file in your new theme Magento_Customer/layout/customer_account.xml with these contents :

customer_account.xml

<?xml version="1.0"?>
<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>
       <referenceBlock name="customer-account-navigation-account-link">
           <arguments>
               <argument name="label" xsi:type="string"
                         translate="true">Awesome new dashboard
               </argument>
           </arguments>
       </referenceBlock>
       <!-- Change Account information -->
       <referenceBlock name="customer-account-navigation-account-edit-link">
           <arguments>
               <argument name="label" xsi:type="string"
                         translate="true">My Profile</argument>
           </arguments>
       </referenceBlock>
    </body>
</page>
0

You need to create customer_account_index.xml at

For custom Module:

app/code/{Vendor}/{Module}/view/frontend/layout/customer_account_index.xml

For Custom Theme

app/design/frontend/{Vendor}/{theme}/Magento_Customer/layout/customer_account_index.xml

<?xml version="1.0"?>
<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-account-edit-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">My Profile</argument>
                <argument name="path" xsi:type="string">customer/account/edit</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Now flush cache and try.

  • it's not working from custom module – Idham Choudry Feb 14 '18 at 6:27
  • Please check layout it must be customer_account_index.xml and it must be at app/code/{Vendor}/{Module}/view/frontend/layout – Prince Patel Feb 14 '18 at 6:31
  • It all depends on the theme you're using. If you're theme does not change it it will work, but if your theme is or extends luma, won't work. See magento documentation link in the comment above. – drew7721 Feb 14 '18 at 13:48
  • @IdhamChoudry I tested this code with a custom module and it's working fine. Please try after flushing cache. – Prince Patel Feb 14 '18 at 18:19
0

You can change the order by changing the number here in the XML's

<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">Order History</argument>
                <argument name="sortOrder" xsi:type="number">220</argument>
            </arguments>
        </block>
    </referenceBlock>
</body>

So if you want sales order history to be next to My dashboard you'd need to change 220 to 240. Its 240 because the dashboard order number is 250.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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