5

My existing code creates a menu that looks like this.

custom magento menu

But I want a menu that is a sub-menu of the Catalog menu.

Here is my existing code in adminhtml.xml

<?xml version="1.0" ?>
<config>
    <menu>
        <mycustom_menu translate="title" module="brands">
            <title>My Custom Menu Item</title>
            <sort_order>300</sort_order>
            <children>
                <!-- child items go here -->
                <subitem translate="title" module="brands">
                    <title>Manage Brands</title>
                    <sort_order>10</sort_order>
                    <action>adminhtml/mycustom_controller/</action>
                </subitem>
            </children>
        </mycustom_menu>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <mycustom_menu translate="title" module="brands">
                        <title>My Custom Menu Item</title>
                        <sort_order>300</sort_order>
                        <children>
                            <subitem translate="title" module="brands">
                                <title>Subitem</title>
                                <sort_order>10</sort_order>
                            </subitem>
                        </children>
                    </mycustom_menu>
                </children>
            </admin>
        </resources>
    </acl>
</config>

2 Answers 2

24

Instead of using <mycustom_menu> you need to re-use the nodename that was used in the adminhtml.xml of the catalog module. That name is catalog.

So your XML should look like:

<?xml version="1.0"?>
<config>
    <menu>
        <catalog>
            <children>
                <your_subitem>
                    <title>Subitem 1</title>
                    <sort_order>10</sort_order>
                    <action>adminhtml/your_action</action>
                </your_subitem>
            </children>
        </catalog>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <catalog>
                        <title>Subitem 1</title>
                        <sort_order>10</sort_order>
                    </catalog>
                </children>
            </admin>
        </resources>
    </acl>
</config>
2
  • 1
    When i try to add this code in the config.xml , the default catalog name was replaced with subitem in the acl roles. how can i correct it.
    – Naveenbos
    Commented Oct 8, 2015 at 5:38
  • @Naveenbos you are right, code for the ACL is not correct, should be ` <acl> <resources> <admin> <children> <catalog> <children> <your_subitem> <title>Subitem 1</title> <sort_order>10</sort_order> </your_subitem> </children> </catalog> </children> </admin> </resources> </acl>`
    – electroid
    Commented Mar 12, 2016 at 8:37
0

For example to add submenu in customer tab:

<menu>
    <customer>
        <children>
          <vendor module="yourmodule">
            <title>Your Title</title>
            <sort_order>0</sort_order>
            <action>admin_yourmodule/adminhtml_yourmoduleaction</action>
          </vendor>
        </children>
    </customer>
</menu>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.