Magento 2

HOW TO CREATE MENU IN MAGENTO 2 ADMIN

magento-2-admin- menu
My previous tutorial show you how to create a simple module in Magento 2, learn more here: http://www.venustheme.com/how-to-create-magento-2-module/. Today, we continue discuss about Magento 2 admin menu.
 
In Magento 1, menu configuration are located inside etc/adminhtml.xml but in Magento 2 menu configuration are located in etc/adminhtml/menu.xml file
 
 
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/menu.xsd">
    <menu>
        <add id="Ves_HelloWorld::brand" title="Ves Hello World" module="Ves_HelloWorld" sortOrder="30" resource="Ves_HelloWorld::brand"/>
 
<add id="Ves_HelloWorld::brand_head_manage" title="Brand" module="Ves_HelloWorld" sortOrder="10" parent="Ves_HelloWorld::brand" resource="Ves_HelloWorld::brand_head_manage"/>
 
<add id="Ves_HelloWorld::brand_new" title="Add New Brand" module="Ves_HelloWorld" sortOrder="10" parent="Ves_HelloWorld::brand_head_manage" action="veshelloworld/brand/new" resource="Ves_HelloWorld::brand_new"/>
 
<add id="Ves_HelloWorld::brand_head_settings" title="Settings" module="Ves_HelloWorld" sortOrder="20" parent="Ves_HelloWorld::brand_head_manage" resource="Ves_HelloWorld::brand_manage"/>
 
        <add id="Ves_HelloWorld::configuration" title="Configuration" module="Ves_HelloWorld" sortOrder="6"
            parent="Ves_HelloWorld::brand_head_settings" action="adminhtml/system_config/edit/section/vesbrand" resource="Ves_HelloWorld::configuration"/>
    </menu>
</config>
 
The first line:
 
 
<add id="Ves_HelloWorld::brand" title="Ves Hello World" module="Ves_HelloWorld" sortOrder="30" resource="Ves_HelloWorld::brand"/>
 
It is the root parent of your customer menu because you haven’t declared the parent attribute. The title equal what you want show as title for root tag, id need unique, the resource you need inside acl.xml(when you want manage permission for your module)
 
The second line:
 
 
<add id="Ves_HelloWorld::brand_head_manage" title="Brand" module="Ves_HelloWorld" sortOrder="10" parent="Ves_HelloWorld::brand" resource="Ves_HelloWorld::brand_head_manage"/>
 
It’s child of Ves_HelloWorld::brand, if you see parent=”Ves_HelloWorld::brand”, you can consider as container include links child
 
The third line:
<add id="Ves_HelloWorld::brand_new" title="Add New Brand" module="Ves_HelloWorld" sortOrder="10" parent="Ves_HelloWorld::brand_head_manage" <strong>action="veshelloworkd/brand/new"</strong> resource="Ves_HelloWorld::brand_new"/>
 
It’s child of container Ves_HelloWorld::brand_head_manage, with property action=”veshelloworkd/brand/new” the veshelloworld is the frontName of admin – it declared in file etc/adminhtml/routes.xml, brand is a folder inside Controller/Adminhtml, Magento 2 give you the default action Index.php(the file contain the execute() function), but you can add more file such as Edit.php with action=”veshelloworkd/brand/edit”

1 Bình luận

  1. tadacip nói:

    Anadia daily cialis tadacip cipl Ovar viagra medicamento Vale de Cambra v is for viagra Ovar cialis o que ?

Trở về
  • Magento plug-ins
  • Magento plug-ins

    Magento2 gave very good concept called Plugin   we can do what ever after and before core function and also we have...