Magento

Create Custom Admin Menu in Magento 2

Posted On
Posted By Praveen Maurya

Dear Developer, Magento also allows to create the custom admin menu items. So, follow the step by step instruction to create custom admin menu.

Step 1: Configure your custom module

Step 2: Register Your module with Magento

Step 3: Create your custom menu

Step 4: Clean the cache

Step 1: Configure your Custom Module

To configure the custom module, create module.xml inside app/code/Vendor/AdminMenu/etc and add the following to it:

<?xml version="1.0"?>     
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">            
  <module name="Vendor_AdminMenu" setup_version="1.0.0">
  </module>
</config>

Step 2: Register Your Module with Magento

For register your module, create registration.php inside app/code/Vendor/AdminMenu and add the following to the file:

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Vendor_AdminMenu',
    __DIR__
);

Step 3: Create Custom Admin Menu

create menu.xml file inside app/code/Vendor/AdminMenu /etc/adminhtml and add the following code in it:

<?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_AdminMenu::admin_menu" title="My Menu" module="Vendor_AdminMenu" sortOrder="20" resource="Magento_Backend::content"/>         
    <add id="Vendor_AdminMenu::second_menu" title="My Sub Menu" module="Vendor_AdminMenu" sortOrder="1" action="adminmenu/index/index"         parent="Vendor_AdminMenu::admin_menu" resource="Magento_Backend::content" />     
</menu>

</config>

Now, here is a short description of the variables used in the above code:

id: The unique identifier of the custom admin menu.

title: The title that will be shown in the admin menu.

Module: in this case, Vendor_AdminMenu

sortOrder: Prioritize the placement of the custom admin menu.

resource: the rule to identify which admin users can access the custom admin menu.

Action: Set the link to the admin controller.

parent: Used to define the menu upon which the custom menu depends.

Launch the SSH Terminal

Open SSH terminal and go to the root directory of the Magneto 2 store and run the following commands:

php bin/magento setup:upgrade 
php bin/magento setup:di:compile
php bin/magento cache:clean
php bin/magento cache:flush

Now, go to the admin panel of your Magento 2 store, and you will see the new admin menu My Menu with the nested My Sub Menu .

That’s it. Enjoy Coding

Related Post

Latest Post

Tech NewsWhat's Arround

Google Meet is officially getting blur backgrounds in next version

Read More
Posted On
Tech NewsWhat's Arround

Is Really, You Secure With Your Smart Voice Assistant Device ?

Read More
Posted On
Magento

Create Custom Admin Menu in Magento 2

Read More
Posted On
React Native

How to show loader on the image in react-native:

Read More
Posted On
React Native

How to use google-places-autocomplete in react native

Read More
Posted On