We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    In this guide, we are going to show you how to create a custom admin menu in Magento 2.

    The first step is to create a module.

    Let’s give the module a name. Call it: Magemonkey_Newadminmenu

    Then, create registration.php file

    <?php
    MagentoFrameworkComponentComponentRegistrar::register(
        MagentoFrameworkComponentComponentRegistrar::MODULE,
        'Magemonkey_Newadminmenu',
        __DIR__
    );

    create module.xml file in etc/

    <?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="Magemonkey_Newadminmenu" setup_version="1.0.0"></module>
    </config>

    create menu.xml file in etc/adminhtml/

    <?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="Magemonkey_Newadminmenu::first_menu"
                 title="My Main Menu"
                 module="Magemonkey_Newadminmenu"
                 sortOrder="20"
                 resource="Magento_Backend::content" />
    
            <add id="Magemonkey_Newadminmenu::second_menu"
                 title="My Sub Menu"
                 module="Magemonkey_Newadminmenu"
                 sortOrder="1"
                 action="newadminmenu/index/index"
                 parent="Magemonkey_Newadminmenu::first_menu"
                 resource="Magento_Backend::content" />
    
        </menu>
    </config>

    Know the description for element variables in code:

    id: The unique identifier for the custom admin menu
    title: The title will be shown as a menu name
    Module: Magemonkey_Newadminmenu (name of the current module)
    sortOrder: Set custom admin menu order
    resource: The rule for admin users can access the custom admin menu
    Action: Link for admin controller URL
    parent: Name of the parent menu which custom menu depends on sub menu

    After running this command for install that module

    php bin/magento setup:upgrade
    php bin/magento cache:clean

    Now It will be shown in admin menu as seen in the below image.

     

    field_5bfb909c5ccae

      Get a Free Quote