4

Summary:

I'd like to remove the entire Account tab from the Magento 2.0.x mobile menu. Our site doesn't have accounts for users, it's more like a catalog with no purchasing.

I've found many examples of how to remove items from the Account tab, but none to remove the tab itself.

Steps already taken:

  • I'm working in developer mode with cache disabled.
  • I've overridden app/code/Magento/Customer/view/frontend/layout/customer_account.xml to remove the customer_account_navigation block, but the menu still shows:

e.g. <my_theme_dir>/Magento_Customer/layout/customer_account.xml

<?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" remove="true" />
    </body>
</page>
  • I've tried removing the block in default.xml in the same folder above. Didn't work.
  • I've done a bin/magento setup:di:compile and bin/magento cache:clear after updating the XML just to be sure that wasn't required. Neither helped.
  • I've hunted all throughout the code base to find anything related to "Account" or the navigation menu. Nothing I found and changed removed the tab.

Questions:

  1. Am I overriding the correct file?
  2. Am I overriding it in the correct location in my theme directory?
6

Add this code in you active theme's default.xml

<referenceContainer name="page.top">
   <referenceBlock name="store.links" remove="true" />
</referenceContainer>

And run command

 - php bin/magento cache:clean
|improve this answer|||||
  • Knowing where the theme's default.xml is located is tricky to a newbie. We ended up editing default.xml located in <theme_dir>/Magento_Theme/layout/default.xml. This worked, but is there another default.xml you are referencing? – John Sanders Mar 3 '17 at 1:27
  • No, just make sure that make this changes in active theme app/design/frontend/<vendor>/<theme_dir>/Magento_Theme/layout/default.xml. – Dipesh Rangani Mar 3 '17 at 4:46
1

First copy the whole customer_account.xml with content to your theme. and before the tag just add <referenceBlock name="customer_account_navigation" remove="true" /> . It's worked for me

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page layout="2columns-left" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="sidebar.main">
            <block class="Magento\Framework\View\Element\Template" name="customer_account_navigation_block" template="Magento_Theme::html/collapsible.phtml" before="-">
                <arguments>
                    <argument name="block_title" translate="true" xsi:type="string">Account Dashboard</argument>
                    <argument name="block_css" xsi:type="string">block-collapsible-nav</argument>
                </arguments>
                <block class="Magento\Framework\View\Element\Html\Links" name="customer_account_navigation" before="-">
                    <arguments>
                        <argument name="css_class" xsi:type="string">nav items</argument>
                    </arguments>
                    <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-account-link">
                        <arguments>
                            <argument name="label" xsi:type="string" translate="true">Account Dashboard</argument>
                            <argument name="path" xsi:type="string">customer/account</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-account-edit-link">
                        <arguments>
                            <argument name="label" xsi:type="string" translate="true">Account Information</argument>
                            <argument name="path" xsi:type="string">customer/account/edit</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-address-link">
                        <arguments>
                            <argument name="label" xsi:type="string" translate="true">Address Book</argument>
                            <argument name="path" xsi:type="string">customer/address</argument>
                        </arguments>
                    </block>
                </block>
            </block>
        </referenceContainer>
        <referenceBlock name="customer_account_navigation" remove="true" />
    </body>
</page>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.