0

this is my code: etc/adminhtml.xml:

<?xml version="1.0"?>
<config>
    <menu>
        <attributegrouping translate="title">
            <title>Attribute Grouping</title>
            <sort_order>210</sort_order> 
            <children>
                <system_configuration translate="title" module="attributegrouping">
                    <title>Add new group</title>
                    <sort_order>20000</sort_order>
                    <action>attributegrouping/addgroup</action>
                </system_configuration>
            </children>
        </attributegrouping>
    </menu>

this is the etc/config.xml :

<?xml version="1.0"?>
<config>
    <modules>
        <Netgroup_Attributegrouping>
            <version>0.1.0</version>
        </Netgroup_Attributegrouping>
    </modules>

    <global>
        <helpers>
          <attributegrouping>
            <class>Netgroup_Attributegrouping_Helper</class>
          </attributegrouping>
        </helpers>
    </global>
</config>

this is the controllers/AddgroupController.php content:

<?php

class Netgroup_Attributegrouping_Adminhtml_AddgroupController extends Mage_Adminhtml_Controller_Action
{
        public function indexAction() 
        {
                echo 1;
        }

}

I want when i click on the "Add new group" in admin menu, to go to a controller function and display smth. in my case to the indexAction from class Netgroup_Attributegrouping_Adminhtml_AddgroupController. How should i do that ? thx

2

Change the <action> tag in your menu to

First add this in your config.xml as a sibling to the <global> tag. This will register your route.

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Netgroup_Attributegrouping before="Mage_Adminhtml">Netgroup_Attributegrouping_Adminhtml</Netgroup_Attributegrouping>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

Then change the <action> for your menu item from adminhmtl.xml to

<action>adminhtml/addgroup/index/</action>

And one more thing. Make sure the class Netgroup_Attributegrouping_Adminhtml_AddgroupController is located in Netgroup/Attributegrouping/controllers/Adminhtml/AddgroupController.php

  • what before="Mage_Adminhtml" does it mean ? – Attila Naghi Jul 24 '14 at 10:28
  • @Chester. It means that before looking for a controller in Mage_Adminhtml it will look for one in your module. – Marius Jul 24 '14 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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