Question

I want to override the following controller which creates orders in the backend:

app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php

I have copied the file itself into:

app/code/community/Pinto/PartnerSystem/Adminhtml/controllers/Sales/Order/CreateController.php

For the sake of not being sure where or how exactly to copy the file/directory structure I also copied it into:

app/code/community/Pinto/PartnerSystem/controllers/AdminControllers/Sales/Order/CreateController.php

I then renamed the class to:

class PartnerSystem_Adminhtml_Sales_Order_CreateController extends Mage_Adminhtml_Sales_Order_CreateController 
{ 
// functions 
}

In my config.xml I have added the following:

<admin>
        <routers>
            <partnersystem>
                <use>admin</use>
                <args>
                    <module>Pinto_PartnerSystem_AdminControllers</module>
                    <frontName>partnersystemadmin</frontName>
                </args>
            </partnersystem>
            <adminhtml>
                <args>
                    <modules>
                        <partnersystem before="Mage_Adminhtml">PartnerSystem_Adminhtml_Sales_Order_CreateController</partnersystem>
                    </modules>
                </args>
            </adminhtml>
        </routers>  
    </admin>

I'm not quite sure as to what I should put between the to make it use my CreateController.php instead of the base one.

Quite new to Magento so could use some help :)

Was it helpful?

Solution

The correct path of your new controller is : app/code/community/Pinto/PartnerSystem/controllers/Adminhtml/Sales/Order/CreateController.php (switch the folders controllers and Adminhtml). This line from config:

<partnersystem before="Mage_Adminhtml">PartnerSystem_Adminhtml_Sales_Order_CreateController</partnersystem>

should be

<partnersystem before="Mage_Adminhtml">Pinto_PartnerSystem_Adminhtml</partnersystem>

and in your new controller file, before the class definitions add this

require_once 'Mage/Adminhtml/controllers/Sales/Order/CreateController.php'  

[EDIT]
The new controller class name should be Pinto_PartnerSystem_Adminhtml_Sales_Order_CreateController.

OTHER TIPS

This is a little notification on the include path of the controller.

This include path can cause errors if the Magento Compiler mode is turned on.

require_once 'Mage/Adminhtml/controllers/Sales/Order/CreateController.php';

Instead of that it is good to use

require_once Mage::getModuleDir('controllers', 'Mage_Adminhtml').DS.'Sales_Order_CreateController.php';

It will be safer. Hope this helps..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top