Magento 2 add sub menu into main menu
-
07-02-2021 - |
Question
How to add submenu into the main menu of the different module in admin panel
Solution
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>
OTHER TIPS
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange