Magento – Extending magento sales order controller not working

admin-controllermagento-1.9sales-order

I'm trying to extend the mage order controller, but i'm getting a 404 error. As far as i can tell my custom ordercontroller is not being included. I've read multiple Q&A's on stackexchange but i can't find anything out of the ordinary in my code.

Below is how my module is build up:

app/etc/modules/Bromo_Orderstatus.xml

<?xml version="1.0" ?>
<config>
    <modules>
        <Bromo_Orderstatus>
            <active>true</active>
            <codePool>local</codePool>
        </Bromo_Orderstatus>
    </modules>
</config>

app/code/local/Bromo/Orderstatus/etc/config.xml

<config>
    <modules>
        <Bromo_Orderstatus>
            <version>1.0.0</version>
        </Bromo_Orderstatus>
    </modules>
    <global>
        <blocks>
             <adminhtml>
                <rewrite>
                    <sales_order_view>Bromo_Orderstatus_Block_Adminhtml_Sales_Order_View</sales_order_view>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <use>admin</use>
                <args>
                    <modules>
                        <orderstatus before="Mage_Adminhtml_Sales">Bromo_Orderstatus_Adminhtml</orderstatus>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

app/code/local/Bromo/Orderstatus/Block/Adminhtml/Sales/Order/View.php

<?php
class Bromo_Orderstatus_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View {
    public function  __construct() {
        $message = Mage::helper('sales')->__('Weet je zeker dat je de klant een klaar voor afhalen e-mail wil versturen?');
        $this->_addButton('afhalenmail', array(
            'label'     => Mage::helper('Sales')->__('Stuur afhaal E-mail (nog niet gebruiken!)'),
            'onclick'   => "confirmSetLocation('{$message}', '{$this->getUrl('*/*/afhalenmail')}')"
            ));
        parent::__construct();
    }   
}

app/code/local/Bromo/Orderstatus/controllers/Adminhtml/Sales/OrderController.php

<?php
require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';

class Bromo_Orderstatus_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController {

    public function afhalenmailAction() {

         echo 'Test action';

    }

}

Who would be so kind to be able to tell me what i'm missing here?

Edit1:
The button is showing absolutely fine, works too (goes to the correct page with showing an confirm message beforehand). Cache etc has already been refreshed.

The problem lays somewhere in my custom controller not being called or some sort.

Best Answer

Change below code:

<admin>
        <routers>
            <adminhtml>
                <use>admin</use>
                <args>
                    <modules>
                        <orderstatus before="Mage_Adminhtml_Sales">Bromo_Orderstatus_Adminhtml</orderstatus>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

to:

<admin>
        <routers>
            <adminhtml>
                <use>admin</use>
                <args>
                    <modules>
                        <orderstatus before="Mage_Adminhtml">Bromo_Orderstatus_Adminhtml</orderstatus>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

Change controller code as below:

<?php
require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';

class Bromo_Orderstatus_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController {

    public function afhalenmailAction() {

         echo 'Test action';

    }

}
Related Topic