1

I'm trying to re-order the links in the Customer Account (mysite.com/customer/account/) of my site. I've created:

#app/design/frontend/Mike/sitename/Magento_Customer/layout/customer_account.xml

<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>

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

    <!-- Won't move the Newsletter Subscription link to the bottom of the nav bar! -->
    <referenceBlock name="customer-account-navigation-newsletter-subscriptions-link" after="-"/>

</body>

Any idea why it won't work? Is the order of the links set elsewhere in Magento – in the admin area and stored in the database, for example..? Is there a problem with the XML above?

I've cleaned all cache and have run magento setup:static-content:deploy en_US but it does nothing. As I've noted in the code snippet, the My Credit Cards link is removed successfully, but the Newsletter link doesn't move anywhere.

2 Answers 2

1

Managed to move it by doing something not that obvious... I 'moved' the element from its original location, customer_account_navigation, and placed it back there, at the same time telling M2 to place it after everything else.

#app/design/frontend/Mike/sitename/Magento_Customer/layout/customer_account.xml 

<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>

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

    <!-- Now works! -->
    <move element="customer-account-navigation-newsletter-subscriptions-link" destination="customer_account_navigation" after="-" />

</body>

Hope this helps someone!

0

As of M2.2.6 there is a new block class that allows to directly adjust the postion on the links. Use

<referenceBlock name="customer-account-navigation-orders-link">
        <arguments>
            <argument name="sortOrder" xsi:type="number">100</argument>
        </arguments>
    </referenceBlock>

to re-order existing links and

<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-your-block-name">
            <arguments>
                <argument name="path" xsi:type="string">module/path</argument>
                <argument name="label" xsi:type="string" translate="true">Your Title</argument>
                <argument name="sortOrder" xsi:type="number">290</argument>
            </arguments>
        </block>

to position new links.

In any customer_account.xml in a module or theme

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.