如何覆盖管理员发票控制器

时间:2016-03-07 13:24:17

标签: magento magento-1.9

我正在尝试覆盖管理销售/订单/发票控制器。我尝试了一切,但它没有覆盖。以下是代码:

配置文件:

<?xml version="1.0" encoding="utf-8"?>
 <config>
    <admin>
    <routers>
        <adminhtml>
            <use>admin</use>     
            <args>
                <modules><TW_Printinvoice before="Mage_Adminhtml">TW_Printinvoice_Adminhtml</TW_Printinvoice>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

带路径的控制器文件:app/code/local/TW/Printinvoice/controllers/Adminhtml/Sales/Order/

require_once 'Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php';
class TW_Printinvoice_Adminhtml_Sales_Order_PrintController extends    Mage_Adminhtml_Sales_Order_InvoiceController
{
    public function printAction()
    {
        die('Testing'); 
    }
}

2 个答案:

答案 0 :(得分:3)

在控制器文件中尝试此代码。的 InvoiceController.php

<?php
require_once 'Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php';
class TW_Printinvoice_Adminhtml_Sales_Order_InvoiceController extends Mage_Adminhtml_Sales_Order_InvoiceController
{
    public function printAction()
    {
        die('Testing'); 
    }
}
?>

希望这可以帮助你!!

答案 1 :(得分:0)

试试这个配置:


<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <TW_Printinvoice  before="Mage_Adminhtml">TW_Printinvoice_Adminhtml_Sales_Order</TW_Printinvoice >
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>