0

How to add submenu into the main menu of the different module in admin panel

1

First of all, find out menu id of the existing module from

app/code/Vendor/ModuleOne/etc/adminhtml/menu.xml

Now use this menu id as parent to show your menu as a submenu of main module menu

<?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 action="Vendor_Module/action/index" id="Vendor_Module::my_id" module="Vendor_Module" parent="Vendor_ModuleOne::module_one_id" resource="Vendor_ModuleOne::module_one_resource" title="My SubMenu"/>
    </menu>
</config>
1

Create menu.xml file at app/code/VendorName/ModuleName/etc/adminhtml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Magento/Backend/etc/menu.xsd">
   <menu>

        <add id="Vendor_Module::view" title="Vendor Module" module="Vendor_Module" sortOrder="11" resource="Vendor_Module::view" parent="Magento_Catalog::catalog"/>

        <add id="Vendor_Module::manage" title="Manage Module" module="Vendor_Module" sortOrder="11" parent="Vendor_Module::view" action="module/index/index" resource="Vendor_Module::manage"/>        
    </menu>
</config>

First <add> tag is about sub-menu title & second <add> tag is about sub-menu.

This menu will create under catalog menu.

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.