How can I extend/override admin create order controller?
-
29-09-2020 - |
Question
I am trying to override adminhtml_sales_order_create controller. I have created a small module app/code/local/PA/Sales/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<PA_Sales>
<version>0.1</version>
</PA_Sales>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<sales before="Mage_Adminhtml">PA_Sales_Adminhtml</sales>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
and created controller file as
app/code/local/PA/Sales/controllers/Adminhtml/CreateorderController.php
<?php
require_once 'Mage/Adminhtml/controllers/Sales/Order/CreateController.php';
class PA_Sales_Adminhtml_CreateorderController extends Mage_Adminhtml_Sales_Order_CreateController
{
public function indexAction()
{
echo "something";exit;
}
}
I am unable to override this controller, where did I go wrong?
Solution
you need to put your controller in
app/code/local/PA/Sales/controllers/Adminhtml/Sales/Order/CreateorderController.php
and name your class accordingly.
As a general rule, when rewriting a controller from Mage/Adminhtml/Some/Controller/HereController.php
your new path should be
Namespace/Module/controllers/Adminhtml/Some/Controller/HereController.php
.
So what comes after Adminhtml
in the original controller should be kept after Adminhtml
in your custom controller.