2

I am making a module that adds a button to the Admin order view and allows the user to create a shipment and invoice (among others) once this button is clicked.

I have used an observer to add the button and get the current order_id. I also used setLocation to the onclick parameter of the button.

However, when I press the button, I am presented with a 404 page. I am not sure if the problem is my controller, setLocation url or somthing else. Here is my config.xml:

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

<frontend>
    <routers>
        <acscourier>
            <use>standard</use>
            <args>
                <module>ID_AcsCourier</module>
                <frontName>acscourier</frontName>
            </args>
        </acscourier>
    </routers>
</frontend>

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <id_acscourier before="Mage_Adminhtml">ID_AcsCourier_Adminhtml</id_acscourier>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

<global>
    <events>
        <adminhtml_widget_container_html_before>
            <observers>
                <acscourier>
                    <class>ID_AcsCourier_Model_Observer</class>
                    <method>addButtonVoucher</method>
                </acscourier>
            </observers>
        </adminhtml_widget_container_html_before>
    </events>

    <helpers>
        <acscourier>
            <class>ID_AcsCourier_Helper</class>
        </acscourier>
    </helpers>
</global>
</config>

And this is the button onclick from my observer:.

'onclick'   => 'setLocation(\' '  . Mage::helper('adminhtml')->getUrl('*/acscourier/index', array('order' => $order['order_id'])) . '\')',

My controller (AcsCourierController.php) is under controllers/Adminhtml and begins like this:

class ID_AcsCourier_Adminhtml_AcsCourierController extends Mage_Adminhtml_Controller_Action
{

    public function indexAction() {
        echo "Hello World";
        exit;
    }

}

Again, this module is not supposed to produce any output. Once it completes, it will just redirect back to the order page and (hopefully) present a message. But in order to get there, I first need to sort the 404 thing...

Any help is greatly appreciated...

2

Your URL */acscourier/index points to an AcscourierController.php file (no uppercase C).

The solution is either to rename your controller file (and class name) to AcscourierController or to change your URL to */acs_courier/index

Also I suggest respecting the case in your config.xml by replacing:

    <adminhtml>
        <args>
            <modules>
                <id_acscourier before="Mage_Adminhtml">ID_AcsCourier_Adminhtml</id_acscourier>
            </modules>
        </args>
    </adminhtml>

With:

    <adminhtml>
        <args>
            <modules>
                <ID_AcsCourier before="Mage_Adminhtml">ID_AcsCourier_Adminhtml</ID_AcsCourier>
            </modules>
        </args>
    </adminhtml>
  • 1
    I can't believe I missed this... I have been looking at anything else except case! Sometimes I just forget how much Magento loves its case :-P – swiss_blade Jul 8 '16 at 11:12
  • @swiss_blade yeah unfortunately it's easy to miss. My recommendation is to avoid camelcase in module and file name as much as possible – Raphael at Digital Pianism Jul 8 '16 at 11:13

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.