Read More
Read More
Menu Close

    create admin menu and controller in magento2

    Here we create admin menu and controller in magento2 .

    In previous blog we learn how to Create hello module in magento2 .

    now we create menu and controller in Magento2 admin panel. For this we follow our previous blog Create hello module in magento2 .

    Before starting the code section, let us create the directory structure that we will need for admin menu and controller.

    *Note:- for complete module also include directory structure of blog Create hello module in magento2 .

    Searching for an experienced
    Magento 2 Company ?
    Read More

    app/code/Webkul/Hello/etc/adminhtml
    app/code/Webkul/Hello/Controllers/Adminhtml/Employee

    as our previous blog Create hello module in magento2 we have already a working hello module and now we add admin menu and controller in that module.

    Now, as we have the directory structure ready, we will now create file as per module requirement in given sequence:

    In Magento 1, menu configuration are locate inside adminhtml.xml but in Magento 2 menu configuration is locate menu.xml

    1.First, we have to create the menu configuration file named menu.xml in app/code/Webkul/Hello/etc/adminhtml

    Done!

    Then clear magento cache and go to admin panel. You add new menu, your new menu is appended with(Webkul Menu-> Employee Manager) as following.

    2.Now, we have to create the Admin Controller  file.In Magento2, we need to create separate file for each action of admin under the Controller/Adminhtml folder.

    file named Index.php in app/code/Webkul/Hello/Controller/Adminhtml/Employee

    3. Finally, we will create a route configuration file for admin  named routes.xml in app/code/Webkul/Hello/etc/adminhtml

    4. Now our admin controller is ready when you click your new menu (Webkul Menu >> Employee Manager) then your controller run and output display as following

    output

    Download sample code form github

    Thanks 🙂

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    5 comments

  • Sayyed Huma Naqvi
    Best tutorial till now. but u forgot registration.php file while creating module
    • saachi
      is webkul menu showing in admin panel?
  • saachi
    webkul menu is not showing in admin panel
  • Bilal
    Thanks for the useful post
  • James K
    I think you forgot about registration.php on the previous instruction “Create hello module in magento2”
  • Back to Top