3

In my module, I am setting up my menu like this.

 <menu>
     <catalog>
        <children>
            <rkt_arattr translate="title" module="rkt_arattr">
                <title>Manage My Custom Attribute</title>
                <sort_order>100</sort_order>
                <children>
                    <install_attr translate="title" module="rkt_arattr">
                        <title>Install My Attribute</title>
                        <action>adminhtml/catalog_arattr_install</action>
                        <sort_order>10</sort_order>
                    </install_attr>
                </children>
            </rkt_arattr>
        </children>
     </catalog>
 </menu>

The code that you need to concentrate is action

 <action>adminhtml/catalog_arattr_install</action>

For this value, my url looks like this

www.mydomain.com/admin/catalog_arattr_install/index/key/[key_value]

As per this ulr, Magento expects a controller setup like this.

File : app/code/local/Namespace/Modulename/controllers/Adminhtml/Catalog/Araattr/InstallController.php

<?php
class Namespace_Modulename_Adminhtml_Catalog_Arattr_InstallController extends Mage_Adminhtml_Contorller_Action
{
     public function indexAction()
     {

     }
}

However this is not what I want.. I need my url parse like this.

www.mydomain.com/admin/catalog_arattr/install/key/[key_value]

Means I want the below method get called when click on the menu

File : app/code/local/Namespace/Modulename/controllers/Adminhtml/Catalog/ArattrController.php

<?php
class Namespace_Modulename_Adminhtml_Catalog_ArattrController extends Mage_Adminhtml_Contorller_Action
{
     public function installAction()
     {

     }
}

But it seems that, magento always looks for indexAction() when we setup a menu.

Is there any way to direct to my custom action when click on the menu ?

3

Should be as simple as adding extra parts to the action node.

<action>adminhtml/your_controller/your_action</action>

Check out how the downloads part of the admin section works.

<action>adminhtml/report_product/downloads</action>

Here the controller is Mage_Adminhtml_Report_ProductController and the action is downloadsAction

| improve this answer | |
  • I have already tried adminhtml/catalog_arattr/install/. It didnt work. I will try once more and let you know – Rajeev K Tomy Nov 20 '14 at 8:11
  • 1
    My bad. I just tried adminhtml/catalog_arattr/install/ in wrong adminhtml.xml file. That is why it didnt work. I feel the question is bad now :-( – Rajeev K Tomy Nov 20 '14 at 8:17
  • @programmer_rkt for me the question is still a good one. As it is not so common to do so might not be many other resources on how to do it. – David Manners Nov 20 '14 at 8:18
  • 1
    Doesn't matter as long as you got it sorted - leave this info here though, will certainly prove to explain things to others in the future. – Jonathan Hussey Nov 20 '14 at 8:18
  • 1
    You should know that I love this part of your answer <action>adminhtml/report_product/downloads</action>. This is what I missed. I have searched entire Mage_Catalog module for any clue. But didnt get it. This part increased my believe that "Look into the core. Everytyhing is there." :-) – Rajeev K Tomy Nov 20 '14 at 8:25
2

Your action path should be adminhtml/catalog_arattr/install to define the install section of the path as the action. Each / slash separates the module, the controller and then the action so as you only have 1 slash the action is assumed to be indexAction(). With the above URL the request will target the Namespace_Modulename_Adminhtml_Catalog_ArattrController and inside that installAction(). You will of course need to change the location of the controller to one directory higher up.

| improve this answer | |

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.