2

How to remove an existing menu item (not declared by my module) using my module's menu.xml?

2 Answers 2

3

Let's say the menu item you want to remove is declared like this:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add id="Vendor_Module::test" title="Test" module="Vendor_Module" sortOrder="100" parent="Magento_Backend::content" resource="Vendor_Module::test" />
    </menu>
</config>

You can do the following in your menu.xml to remove that menu item:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <remove id="Vendor_Module::test" />
    </menu>
</config>
2

create layout file in your module at app\code\Vendor\Extension\etc\adminhtml\menu.xml

In this file delete menu by its id.

Let say if you want to remove Now Online menu from customer menu section so your code should be,

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <remove id="Magento_Customer::customer_online" />
    </menu>
</config>

Here is Reference Screenshots
Before :https://i.sstatic.net/mWSZ8.png & After: https://i.sstatic.net/ht4rI.png

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.