如何删除 Magento 2 中不必要的客户帐户链接

Magento 默认情况下会在客户帐户页面上显示大量客户帐户链接列表。如果您的业务与其他业务不同,并且不支持新闻通讯订阅,那么在客户帐户页面显示的链接列表中就没有必要。而且很多时候需要自定义所有默认链接,因为对于客户帐户页面上显示的所有链接没有具体要求。有一些要求可以删除一些对客户来说不必要的链接。

在下面的客户帐户屏幕上显示 Magento 2 默认提供的链接列表: 

  • My Orders
  • My Downloadable Products
  • Account Dashboard
  • Newsletter Subscriptions
  • Stored Payment Methods
  • Address Book
  • Account Information
  • Billing Agreements
  • My Wish List
  • My Product Reviews

如何删除导航链接的步骤

第 1 步:首先,创建自定义扩展或主题并覆盖客户布局文件

创建扩展并覆盖布局 XML 文件

app/design/frontend/[命名空间]/[主题]/Magento_Customer/layout/customer_account.xml

第 2 步:使用标签从我的帐户中删除任何额外的链接。

   <!-- Remove unwanted account navigation links -->

   <!-- Put this file in: app/design/frontend/[Namespace]/[Theme]/Magento_Customer/layout/customer_account.xml -->

   <!-- Store credit -->

   <referenceBlock name="customer-account-navigation-customer-balance-link" remove="true"/>

   <!-- Downloadable product link -->

   <referenceBlock name="customer-account-navigation-downloadable-products-link" remove="true"/>

   <!-- Subscription link -->

   <referenceBlock name="customer-account-navigation-newsletter-subscriptions-link" remove="true"/>

   <!-- Billing agreement link -->

   <referenceBlock name="customer-account-navigation-billing-agreements-link" remove="true"/>

   <!-- Product review link -->

   <referenceBlock name="customer-account-navigation-product-reviews-link" remove="true"/>

   <!-- My credit card link -->

   <referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>

   <!-- Account link -->

   <referenceBlock name="customer-account-navigation-account-link" remove="true"/>

   <!-- Account edit link -->

   <referenceBlock name="customer-account-navigation-account-edit-link" remove="true"/>

   <!-- Address link -->

   <referenceBlock name="customer-account-navigation-address-link" remove="true"/>

   <!-- Orders link -->

   <referenceBlock name="customer-account-navigation-orders-link" remove="true"/>

   <!-- Wish list link -->

   <referenceBlock name="customer-account-navigation-wish-list-link" remove="true"/>

   <!-- Gift card link -->

   <referenceBlock name="customer-account-navigation-gift-card-link" remove="true"/>

   <!-- Order by SKU -->

   <referenceBlock name="customer-account-navigation-checkout-sku-link" remove="true"/>

   <!-- Gift registry -->

   <referenceBlock name="customer-account-navigation-giftregistry-link" remove="true"/>

   <!-- Reward points -->

   <referenceBlock name="customer-account-navigation-reward-link" remove="true"/>

第 3 步:现在,只需清除缓存并验证“我的帐户”页面上的链接将被删除。