1

I have tried to add a Custom link to my Magento Account page side-bar. but cannot add even I cannot remove as well. I added

Magento_Customer/layout/customer_account.xml

and copied the customer_account.xml from module_customer and paste but nothing is happening.

3
  • update your xml file which you have changed Oct 16, 2019 at 9:17
  • @Rakesh Varma. Sir, can you please help?? Oct 16, 2019 at 9:19
  • update your xml file in question. Oct 16, 2019 at 9:23

2 Answers 2

1

You can use below content for you customer_account.xml to add new link there in My Account sidebar section

<?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>
        <referenceBlock name="customer_account_navigation">
            <block class="Magento\Framework\View\Element\Html\Link\Current" name="custom-link-left-sidebar">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">Custom Link Left Sidebar</argument>
                    <argument name="path" xsi:type="string">custom/index/index</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

In above content you can use your Block class name instead of using Magento\Framework\View\Element\Html\Link\Current this

You can remove any link using below line in your xml file

<referenceBlock name="your-block-name" remove="true" />

You can add your block name where I have mentioned 'your-block-name'. For e.g. If you want to remove wishlist link then you can find block name of wishlist link here in this file..

vendor/magento/module-wishlist/view/frontend/layout/customer_account.xml

there is one block with this name "customer-account-navigation-wish-list-link" that is your wishlist link block you can use this name in referenceBlock name and just add remove="true" after it.

After adding this you can clear and flush cache using commands

php bin/magento cache:clean
php bin/magento cache:flush

Hope this may help you!

10
  • Thanks a lot, Sir. It worked for me. May I ask you how to remove a link? Oct 16, 2019 at 9:47
  • Which link you want to remove ? Oct 16, 2019 at 9:55
  • I've updated my answer, you can check that. If it will work for you then you can accept my answer and upvote ;) Oct 16, 2019 at 10:05
  • wish list. and is it possible to add a phtml file?? Oct 16, 2019 at 10:24
  • I've updated answer for wishlist. please check that and where you want to add phtml file ? Oct 16, 2019 at 10:25
2

Add xml file in your theme layout customer_account.xml and add that code in xml file

<referenceBlock name="customer_account_navigation">
    <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-custom-link" after="-" >
         <arguments>
             <argument name="label" xsi:type="string" translate="true">Custom Label</argument>
             <argument name="path" xsi:type="string">my-path-url</argument>
         </arguments>
    </block>
</referenceBlock>

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.