我正在尝试覆盖 magento 类
class Mage_Adminhtml_Controller_Sales_Invoice extends Mage_Adminhtml_Controller_Action
我创建了一个主管和文件 local/myModules/Adminhtml/Controller/Sales/Invoice.php,它的代码是。
include_once("Mage/Adminhtml/controller/Sales/Invoice.php");
class myModules_Adminhtml_Controller_Sales_Invoice extends Mage_Adminhtml_Controller_Sales_Invoice
{
public function printAction()
{
echo "child class";exit;
if ($invoiceId = $this->getRequest()->getParam('invoice_id')) {
if ($invoice = Mage::getModel('sales/order_invoice')->load($invoiceId)) {
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));
$this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').
'.pdf', $pdf->render(), 'application/pdf');
}
}
else {
$this->_forward('noRoute');
}
}
}
而 local/myModules/Adminhtml/config.xml 是
<?xml version="1.0"?>
<config>
<modules>
<myModules_Adminhtml>
<version>1.1</version>
</myModules_Adminhtml>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<sales_order_view>myModules_Adminhtml_Block_Sales_Order_View</sales_order_view>
</rewrite>
</adminhtml>
</blocks>
</global>
<admin>
<routers>
<adminhtml>
<use>admin</use>
<args>
<modules>
<myModules_Adminhtml before="Mage_Adminhtml">myModules_Adminhtml</myModules_Adminhtml>
</modules>
</args>
</adminhtml>
</routers>
</admin>
在浏览器中我有网址
/index.php/admin/sales_order_invoice/print/invoice_id/49191/
但它不显示“子类”;
实际上我想覆盖发票打印功能。我在 XML 中缺少什么?