Magento2 Layout – How to Add My Order Link in My Account Dropdown

layoutmagento2

I have overriden app/code/Test/Sales/view/frontend/layout/default.xml file

  <referenceBlock name="top.links">
        <block class="Magento\Sales\Block\Order\Link" name="order-list-link" after="wish-list-link"/>
    </referenceBlock>

 <move element="top.links" destination="customer"/>

But no effect.

Best Answer

Add default.xml in app/design/frontend/your-theme-namespace/yourtheme/Magento_Sales/layout with following content

<?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="top.links">
            <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-orders-link-top" 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>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

My Orders link will appear as in the image.
enter image description here
I hope this will be helpful.

Related Topic