In this blog post, we’ll create a custom module to understood you how to create a custom admin menu in Magento 2.
Let’s follow the steps given below:
Step -1: Create registration.php file
1 2 3 4 5 6 7 8 |
Path: app/code/Webiators/CustomChanges/registration.php <?php use Magento\Framework\Component\ComponentRegistrar; ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Webiators_CustomChanges', __DIR__); |
Step -2: Create module.xml file
1 2 3 4 5 6 7 8 9 |
Path: app/code/Webiators/CustomChanges/etc/module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Webiators_CustomChanges" setup_version="1.0.0"> </module> </config> |
Step -3: Create routes.xml file
1 2 3 4 5 6 7 8 9 10 11 |
Path: app/code/Webiators/CustomChanges/etc/adminhtml/routes.xml <?xml version="1.0" ?> <config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='urn:magento:framework:App/etc/routes.xsd'> <router id='admin'> <route id='wtcustomchanges' frontName='wtcustomchanges'> <module name='Webiators_CustomChanges' before='Magento_Backend' /> </route> </router> </config> |
1 2 3 4 5 6 7 8 9 10 |
Path: app/code/Webiators/CustomChanges/etc/menu.xml <?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="Webiators_CustomChanges::view" title="Custom Changes" module="Webiators_CustomChanges" sortOrder="51" resource="Webiators_CustomChanges::view"/> <add id="Webiators_CustomChanges::customchanges" title="Custom Menu" module="Webiators_CustomChanges" sortOrder="10" action="wtcustomchanges/customchanges" resource="Webiators_CustomChanges::customchanges" parent="Webiators_CustomChanges::view"/> </menu> </config> |
Step -5: Run the following commands
1 2 3 4 5 6 7 |
php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f en_US php bin/magento cache:clean php bin/magento cache:flush php bin/magento indexer:reindex |
We hope this post is very helpful to you. If you have any doubts related to this post you can contact us.
Thank You!
Hit 5 Stars if you find this post helpful
0 (based on 0 Reviews)