Adding Your Extension to Magento Admin Menu Sidebar
As a new extension developer for Magento, you’re eager to make your first community extension available in the admin area so customers can enable or disable it easily. In this post, we’ll guide you through adding your extension to the Magento admin menu sidebar.
Understanding the Basics
Before diving into the code, let’s clarify a few key concepts:
- Admin Menu Sidebar: This is where you want to add your new extension for easy access in the Magento backend.
- Extension Configuration Files: The main files responsible for adding an extension to the admin menu are
etc/adminhtml.xml,etc/system.xml, andetc/config.xml.
Step 1: Adding Your Extension to the Admin Menu Sidebar
Open the etc/adminhtml.xml file located in your module’s directory.
<menu>
<modulename translate="title" module="shipping">
<title>Module</title>
<sort_order>15</sort_order>
<children>
<modulename translate="title" module="modulename">
<title>Drop Down Shipping</title>
<sort_order>1</sort_order>
<action>adminhtml/shipping/index</action>
</example>
</children>
</modulename>
</menu>
In this file, you’re defining a new menu item named “Module” with a sort order of 15. Inside the Module menu, you’ve created another menu item called “Drop Down Shipping”.
The important parts to note are:
<title>: This is the label that will appear in the admin menu.<sort_order>: Determines the position of your extension in the menu.<action>: The URL of the page associated with this menu item.
Step 2: Defining Your Extension’s Configuration
Next, open the etc/system.xml file to define your module’s configuration section and fields.
<config>
<sections>
<module translate="label" module="modulename">
<label>Your Module Name</label>
<tab>tab_id_where_you_want_to_add_your_section</tab>
<!-- ... -->
</module>
</sections>
</config>
Here, you’re naming your section “Your Module Name” and placing it under a tab specified by tab_id_where_you_want_to_add_your_section.
Step 3: Configuring Your Extension
Finally, modify the etc/config.xml file to include helper definitions for your module.
<config>
<modules>
<Module_Name>
<!-- ... -->
</Module_Name>
</modules>
<frontend>
<layout>
<updates>
<modulename>
<file>shipping.xml</file>
</modulename>
</updates>
</layout>
</frontend>
<global>
<helpers>
<modulename>
<class>Module_Name_Helper</class>
</modulename>
</helpers>
</global>
</config>
In this file, you’re defining the version of your module and specifying a helper class named Module_Name_Helper.
Conclusion
By following these steps and modifying the necessary configuration files, you can successfully add your extension to the Magento admin menu sidebar. This will provide customers with an easy way to enable or disable your extension right from their backend.
Remember to replace placeholders like <modulename> and Module_Name with the actual name of your module throughout these files.
For further reference on Magento extension development, we recommend exploring Laravel Company’s guide on Magento 2 Extension Development.
Happy coding!