Magento 2, as a flexible and feature-rich platform, allows developers to customize almost every part of the store. One common request is to Remove customer account link in Magento 2. Whether you want to hide the Orders, Wishlist, or Newsletter Subscriptions links, Magento 2 offers a simple way to customize the customer account menu using layout XML files.
In this guide, I’ll show you step-by-step how to remove links from the customer account menu in Magento 2. By the end of this post, you’ll have the know-how to streamline your account menu and improve your store’s user experience.
Why Customize the Customer Account Menu?
Customizing the customer account menu helps in multiple ways:
- Improved User Experience (UX): If certain links aren’t relevant to your store’s functionality, removing them prevents confusion and improves navigation.
- Security and Privacy: Some links, such as Billing Agreements or Address Book, might be unnecessary for your store. Removing these helps minimize exposed data fields.
- Customization: If you’re offering a streamlined or minimalistic user interface, having fewer options in the account menu can align with your overall design goals.
Steps to Remove Customer Account Link in Magento 2
Step 1: Create or Modify a Layout XML File
The easiest way to remove a customer account menu link is by modifying the layout XML file. Depending on whether you’re working on a custom theme or a custom module, the location of the XML file will differ.
For Themes:
Navigate to your theme’s layout directory:
1 |
app/design/frontend/[Vendor]/[Theme]/Magento_Customer/layout/customer_account.xml |
For Modules:
If you’re working with a custom module, the layout file will be located here:
1 |
app/code/[Vendor]/[Module]/view/frontend/layout/customer_account.xml |
Step 2: Add the XML Code to Remove the Link
Inside the customer_account.xml
file, you can remove any link by adding the following XML block:
1 2 3 4 5 6 7 |
<?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="customer-account-navigation-my-credit-cards-link" remove="true"/> </body> </page> |
Replace name="customer-account-navigation-my-credit-cards-link"
with the specific block name of the link you want to remove.
Deploy Changes and Clear the Cache
After adding the XML code to remove the desired link, you need to deploy the static content and clear the Magento cache to apply the changes. Here are the necessary commands to run:
1 2 3 |
bin/magento setup:upgrade bin/magento setup:static-content:deploy bin/magento cache:clean |
That’s it, you will see that the specific link has been removed from the account menu.
Happy Coding !!
You may also like,
How to Remove Blocks or Containers From Layout in Magento 2?