Magento 2 is a great site that lets you set up an e-commerce store for your online business. One of the great things about using Magento 2 to run your e-commerce store is that the admin menu works really well and can help you find certain features of the site.
To help store owners even more when using Magento 2, there is an added feature that lets you customise the admin menu. This is great because it lets users have exactly what they need in the admin menu to make their site easier to manage. In this post, we are going to take you through the steps to follow when creating a customer admin menu in Magento 2 but don’t worry as they are not too difficult as long as you can follow the code. Keep reading to find out more.
How To Create Custom Admin Menu
To get started on your custom admin menu, you’ll first need to create a custom module. The new module that you create in Magento 2 needs to be configured so make sure to find app/code/Yoursite/Newmenu/etc and create module.xml in it. From here, you’ll need to add the following code:
<config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Module/etc/module.xsd”>
<module name=”Yoursite_Newmenu” setup_version=”1.0.1″></module>
Once your module has been configured, you will need to register it. Find app/code/Yoursite/Newmenu again and create something called registration.php. You should then add the following code:
Creating The Custom Admin Menu
The next step is to create your Magento 2 admin menu by creating a file named menu.xml in app/code/Yoursite/Newmenu/etc/adminhtml. From here, you should add the following code:
<config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:module:Magento_Backend:etc/menu.xsd”>
title=”My Main Menu”
title=”My Sub Menu”
If you are unsure of what some of these labels in the code mean, we’ll take you through some of the more complicated ones. For sortOrder, you’ll want to choose where you want it to be placed. For resource, you should choose the rule which helps to figure out which users can access the menu. For parent, you’ll want to choose the menu that your new menu depends on.
Once you have entered all of the above code, you’ll need to take the final steps to make sure that your custom admin menu in Magento 2 is created properly. To do this, you’ll need to launch the SSH terminal. Once you’ve done this, you’ll need to find the root directory of your store. From here, you should be able to see your new admin menu. It should be labelled ‘my main menu’ and have a submenu labelled ‘my sub menu’.