matthijs
matthijs

Reputation: 479

Overriding Core admin controller in Magento 1.7 CE

I am trying to override a controller from the core (Mage/Adminhtml/controllers/Sales/Order/InvoiceController).

My code for this in my custom modules' config.xml:

<modules>
    <admin>
          <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Mycompany_Mymodule before="Mage_Adminhtml">Mycompany_Mymodule_Adminhtml</Mycompany_Mymodule>
                    </modules>
                </args>
            </adminhtml>
          </routers>
      </admin>
</modules>

My controller file is located at: local/mycompany/mymodule/controllers/adminhtml/dueperiodcontroller.php

The route doesn't get here (still uses the core controller).

There might be a way to use mycompany/adminhtml as module and place everything in here. Does this work?

And preferably an easy fix for the way I already did.

Upvotes: 0

Views: 3872

Answers (1)

Asif
Asif

Reputation: 21

  1. module override xml Should be in

>

<config>
    <admin>
          <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Mycompany_Mymodule before="Mage_Adminhtml">Mycompany_Mymodule_Adminhtml</Mycompany_Mymodule>
                    </modules>
                </args>
            </adminhtml>
          </routers>
      </admin>
</config>
  1. Place controller file under the same directory structure and should have same name local/mycompany/mymodule/controllers/Adminhtml/Sales/Order/InvoiceController.php

  2. use class name as follows

>

require_once 'Mage/Adminhtml/controllers/Sales/Order/InvoiceController';
class mycompany_mymodule_Adminhtml_Sales_Order_InvoiceController extends Mage_Adminhtml_Sales_Order_InvoiceController

Upvotes: 2

Related Questions