Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a submenu to an existing menu in Magento?

Tags:

magento

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>
like image 265
desbest Avatar asked Aug 04 '12 13:08

desbest


1 Answers

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>
like image 56
Tim Hofman Avatar answered Oct 04 '22 20:10

Tim Hofman