I am trying to edit the reports generated from here, example.com/index.php/admin/sales_order/index/. I need to add a new report to the dropdown on the right.
I traced this page to it’s controller through the url and dumped the class.
app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php indexAction() and got this class Ext4mage_Html2pdf_Sales_OrderController so I know it’s being overridden by a module. In this case the Ext4mage Html2pdf module.
This controller just overwrites the pdf methods using,
require_once BP.'/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php';
class Ext4mage_Html2pdf_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController{
//etc }
So I’ve created my new module in local, hoping to overwrite this as it’s in community.
app/code/local/Daves/OrderModule/controllers/Sales/OrderController.php and placed in the following.
require_once 'Mage'.DS.'Adminhtml'.DS.'controllers'.DS.'Sales'.DS.'OrderController.php';
require_once BP.'/app/code/community/Ext4mage/Html2pdf/controllers/Sales/OrderController.php';
class Daves_OrderModule_Sales_OrderController extends Ext4mage_Html2pdf_Sales_OrderController{
public function indexAction(){
die();
return parent::indexAction();
}
}
My expected functionality would be that upon reloading the Sales/Order page in admin, I’d get a blank page, and I don’t. Which would mean that my controller isn’t being loaded.
My IDE is showing that the classes are being extended, and putting a die() into an indexAction() method in the Ext4mage_Html2pdf controller works as expected. It’s just missing out my controller for some reason.
Trying to hit the controller directly in a browser using example.com/admin/daves_ordermodule/sales_order/index also throws a 404.
Should I be trying to overwrite the blocks instead?
I’ve not created any funky <rewrite> update handles in my config, mainly because I’m not sure if I need them, or where they would go. As I know Magento takes from Zend in it’s horrific use of xml, I’ll paste in my configs here.
app/etc/modules/Daves_OrderModule.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Daves_OrderModule>
<active>true</active>
<codePool>local</codePool>
<depends> <!-- same as in the /app/etc/Mage_All.xml -->
<Mage_Reports/>
<Mage_Adminhtml/>
<Ext4mage_Html2pdf/>
</depends>
</Daves_OrderModule>
</modules>
</config>
app/code/local/Daves/OrderModule/etc/config.xml
0.1
<global>
<blocks>
<daves_ordermodule> <!-- this is the class group and must be lowercase-->
<class>Daves_OrderModule_Block</class> <!-- this is how you access it -->
</daves_ordermodule>
</blocks>
<helpers>
<daves_ordermodule>
<class>Daves_OrderModule_Helper</class> <!-- Mage::helper('squaresphere_module/<helper>'); -->
</daves_ordermodule>
</helpers>
<models>
<daves_ordermodule>
<class>Daves_OrderModule_Model</class> <!-- Mage::getModel('squaresphere_module/<model>'); -->
</daves_ordermodule>
</models>
</global>
<!-- How to get to the module from the browser -->
<admin>
<routers>
<daves_ordermodule> <!-- My unique class group -->
<use>admin</use> <!-- which router class? -->
<args>
<module>Daves_OrderModule</module> <!-- assumes /controllers -->
<frontName>daves_ordermodule</frontName> <!-- what is on the url -->
</args>
</daves_ordermodule>
</routers>
</admin>
</config>
app/code/community/Ext4mage/Html2pdf/etc/config.xml Specifically nodes
<admin>
<routers>
<html2pdf>
<use>admin</use>
<args>
<module>Ext4mage_Html2pdf</module>
<frontName>html2pdf</frontName>
</args>
</html2pdf>
<emailattachments>
<args>
<modules>
<Ext4mage_Html2pdf before="Fooman_EmailAttachments">Ext4mage_Html2pdf</Ext4mage_Html2pdf>
</modules>
</args>
</emailattachments>
<adminhtml>
<args>
<modules>
<Ext4mage_Html2pdf before="Mage_Adminhtml">Ext4mage_Html2pdf</Ext4mage_Html2pdf>
</modules>
</args>
</adminhtml>
</routers>
</admin>
Assuming you have no frontend controllers, adjust your config as follows:
What this does is add another controllers directory under the Mage_Adminhtml module’s frontname. The value from
<Daves_Om>is essentially mapped to the text node + “controllers”, soapp/code/(configured codepool)/Daves/OrderModule/controllers/– and then the typical route matching applies.