1

Im trying to create a custom route on the administration, but is not working, it gives me a 404.

config.xml:

<global>
...
</global>

    <admin>
        <routers>
            <cloud_magni>
                <use>admin</use>
                <args>
                    <module>Cloud_Magni</module>
                    <frontName>secondinvoice</frontName>
                </args>
            </cloud_magni>
        </routers>
    </admin>
</config>

app/code/local/Cloud/Magni/controllers/Adminhtml/IndexController.php

class Cloud_Magni_IndexController extends Mage_Adminhtml_Controller_Action
{

    public function sayHelloAction(){
        echo "Hello World";
    }
}

The url im accessing is:

https://somedomain.com/index.php/admin/secondinvoice/sayHello/key/018460841df56cd3a7fbe2d720d750d2/
2
  • have u get url via admin menu or direct pass url in browser?
    – Abdul
    Commented Jan 5, 2018 at 7:10
  • can u pls share your full config.xml file code?
    – Abdul
    Commented Jan 5, 2018 at 7:23

3 Answers 3

1

Every time when you have problem with routing use Mage_Core_Controller_Varien_Router_Standard::_validateControllerClassName function to debug controller file path and classname

1
0

Change in your config.xml

...

<admin>
    <routers>
        <adminhtml>
            <use>admin</use>
            <args>
                <modules>
                    <namespace before="Mage_Adminhtml">NameSpace_Module_Adminhtml</namespace>
                </modules>
                <frontName>secondinvoice</frontName>
            </args>
        </adminhtml>
    </routers>
</admin>

Replace your namespace to your NAMESPACE and NameSpace_Module to your own.

UPDATE

change this class Cloud_Magni_IndexController extends Mage_Adminhtml_Controller_Action

to

class Cloud_Magni_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action

4
  • is not working :S
    – Info E
    Commented Jan 5, 2018 at 1:38
  • Check my update. Commented Jan 5, 2018 at 2:41
  • Already made this change, but still no success, have no idea of the problem is the path of the route
    – Info E
    Commented Jan 5, 2018 at 3:03
  • Try to add the menu for this controller and access it from there. Commented Jan 5, 2018 at 3:57
0

Try this:

config.xml

<?xml version="1.0"?>
<config>
    ...
    ...
    ...
    <admin>
        <routers>
            <cloud_magni>
                <use>admin</use>
                <args>
                    <module>Cloud_Magni</module>
                    <frontName>secondinvoice</frontName>
                </args>
            </cloud_magni>
        </routers>
   </admin>
   ...
   ...
   ...   
</config>

IndexController.php

app\code\local\Cloud\Magni\controllers\Adminhtml\IndexController.php

<?php
class Cloud_Magni_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
    /**
     * Method for render layout
     */
    public function sayHelloAction()
    {
        echo "Hello World";
        die;
        $this->loadLayout();
        $this->renderLayout();
    }
}

Note: If your access url via admin top menu then used below code in action tag in config.xml or adminhtml.xml

<action>secondinvoice/adminhtml_index/sayHello</action>

If your used in php & pthml then use below code

$this->getUrl('secondinvoice/adminhtml_index/sayHello', array('_current'=>true));

For eg. <a href="<?php echo $this->getUrl('secondinvoice/adminhtml_index/sayHello', array('_current'=>true)); ?>">Say Hello</a>

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.