Magento 2 – How to Update an Existing Backend Menu Item

adminmenumagento-2.0magento2module

Let's say there's a module that declares a custom admin menu item via menu.xml 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>

How to update (let's say change the label) this menu item via another module's menu.xml ?

Best Answer

It seems like the menu.xml handles the following actions:

  • add
  • remove
  • update

Thus you can something like this to update an existing 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>
        <update id="Vendor_Module::test" title="Updated Test" module="Vendor_Module" sortOrder="100" parent="Magento_Backend::content" resource="Vendor_Module::test" />
    </menu>
</config>