1
votes

I have set up a controller in my module to add an order export tab to my installation:

in config.xml:

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <orderexport>abc_Orderexport_index2</orderexport>
                    </modules>
                </args>
            </adminhtml>
        </routers>
        <layout>
            <updates>
                <orderexport>
                    <file>orderexport.xml</file>
                </orderexport>
            </updates>
        </layout>
    </admin>

in adminhtml.xml:

<?xml version="1.0"?>
<config>
    <menu>
        <sales>
            <children>
                <orderexport>
                    <title>Order Export</title>
                    <sort_order>20</sort_order>
                    <action>adminhtml/index2</action>
                </orderexport>
            </children>
        </sales>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <sales>
                        <children>
                            <orderexport>
                                <title>Order Export</title>
                                <sort_order>20</sort_order>
                            </orderexport>
                        </children>
                    </sales>
                </children>
            </admin>
        </resources>
    </acl>
</config>

and in the controllers/Adminhtml/Index2Controller.php file

class abc_Orderexport_Adminhtml_Index2Controller extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
         $this->loadLayout();
         $this->renderLayout();
    }

}

However with all this done, whenever I click on the button "Order Export" it redirects me to the 404 page. That means that Magento cannot find the controller but idk why.

When i rename the controller everywhere from index2 into index (Index2Controller.php to IndexController.php) I am not getting redirected to the 404 page, HOWEVER the Dashboard of the admin panel just reloads.

I really don't know where my error is and Im happy for any hints into the right direction.

2

2 Answers

1
votes

Here is what you have to fix:

  1. in config.xml: you have to say that your module should be use in the adminhtml area, and you have to respect the CamelCase, here is how it should look like:

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Abc_Orderexport after="Mage_Adminhtml">Abc_Orderexport_Adminhtml</Abc_Orderexport>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    
  2. in your controller, again, you must respect CamelCase, i.e. the class name is Abc_Orderexport_Adminhtml_Index2Controller

All this is assuming your folder structure is:

app/
  code/
     local/
        Abc/
          Orderexport/
               controllers/
                     Adminhtml/
                          Index2Controller.php
               etc/
                 config.xml
                 adminhtml.xml
0
votes

Could you please try the following code and make sure that you module class name and folder structure must be in standard magento extension structure. config.xml

 <admin>
        <routers>
		<orderexport>
		   	<use>admin</use>
		        <args>
		            <modules>
		                <orderexport>Abc_Orderexport_Index2</orderexport>
				<frontName>orderexport</frontName>
		            </modules>
		        </args>
		<orderexport>
        </routers>
        <layout>
            <updates>
                <orderexport>
                    <file>orderexport.xml</file>
                </orderexport>
            </updates>
        </layout>
    </admin>