3

I want my top links in the order like:

  1. My Account
  2. My Wishlist
  3. My Orders
  4. Sign In

But I am getting like:

  1. My Account
  2. My Wishlist
  3. Sign In
  4. My Orders

Below is my code:

<referenceBlock name="top.links">
        <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link" before="my-account-link"
               template="Magento_Customer::account/link/authorization.phtml"/>

        <block class="Magento\Customer\Block\Account\Link" name="my-account-link" after="authorization-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">My Account</argument>
                <argument name="sortOrder" xsi:type="number">110</argument>
            </arguments>
        </block>
        <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-orders-link-top" after="my-account-link" before="-">
            <arguments>
                <argument name="path" xsi:type="string">sales/order/history</argument>
                <argument name="label" xsi:type="string" translate="true">My Orders</argument>
            </arguments>
        </block>

        <block class="Magento\Customer\Block\Account\RegisterLink" name="register-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
            </arguments>
        </block>

    </referenceBlock>
6

1 Answer 1

2

Try the below code instead of yours:

<referenceBlock name="top.links">
    <block class="Magento\Customer\Block\Account\Link" name="my-account-link">
        <arguments>
            <argument name="label" xsi:type="string" translate="true">My Account</argument>
            <argument name="sortOrder" xsi:type="number">110</argument>
        </arguments>
    </block>
    <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">My Orders</argument>
            <argument name="sortOrder" xsi:type="number">40</argument>
        </arguments>
    </block>
    <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link" after="customer-account-navigation-orders-link-top"
           template="Magento_Customer::account/link/authorization.phtml">
        <arguments>
            <argument name="sortOrder" xsi:type="number">10</argument>
        </arguments>
    </block>
</referenceBlock>

Flush the cache and test.

3
  • It is not working. Any new solution? I can't able to reorder the links in the dropdown. Mar 13, 2020 at 10:59
  • Then Magento core top links are not working on your theme. It might handled through different way or code. Mar 13, 2020 at 11:13
  • It works on all pages except customer account pages. Any thoughts why?
    – Mohammed
    Jun 17, 2022 at 12:50

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.