:::: MENU ::::
Posts tagged with: customer navigation

Magento 2 add link customer navigation

Today we discuss about Magento 2 add link customer navigation.This tutorial include how you can add your custom link in customer account navigation, Magento 2 add link customer navigation. So let’s start with our example.

If you are adding it from theme layout then create default.xml in following path.

app/design/frontend/QaisarSatti/theme/Magento_Theme/layout/default.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. 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="test-link">
                    <arguments>
                        <argument name="path" xsi:type="string">test/controller/action</argument>
                        <argument name="label" xsi:type="string">Test Link</argument>
                         <argument name="sortOrder" xsi:type="number">150</argument>
                    </arguments>
                </block>
    </referenceBlock>

  </body>
</page>

Or you want it to add from module layout then create default.xml in following path.

app/code/QaisarSatti/view/HelloWorld/frontend/layout/default.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. 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="test-link">
                    <arguments>
                        <argument name="path" xsi:type="string">test/controller/action</argument>
                        <argument name="label" xsi:type="string">Test Link</argument>
                         <argument name="sortOrder" xsi:type="number">150</argument>
                    </arguments>
                </block>
    </referenceBlock>

  </body>
</page>
Author: Qaisar Satti
Category: Magento 2
Last Modified: August 6, 2018