Few days back I was supposed to integrate pdf library to generate invoice pdf instead of Zend Pdf. For that I tried to override the Invoice print action . Below are the steps you need to follow to override magento admin controller.
STEP 1 : Create simple module Eg TW_Printinvoice , here TW is the namespace and Printinvoice is the module name.
config.xml : This file will be placed under app/etc/code/local/TW/Printinvoice/etc
[codesyntax lang=”xml”]
<?xml version="1.0" encoding="utf-8"?> <config> <modules> <TW_Printinvoice> <version>0.0.1</version> </TW_Printinvoice> </modules> <admin> <routers> <adminhtml> <args> <modules> <TW_Printinvoice before="Mage_Adminhtml">TW_Printinvoice_Adminhtml</TW_Printinvoice> </modules> </args> </adminhtml> </routers> </admin> </config>
[/codesyntax]
Step 2: Create the controller file under the path :app/etc/code/local/TW/Printinvoice/controllers/Adminhtml/Sales/Order/InvoiceController.php
[codesyntax lang=”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() { // write your code here } public function pdfinvoicesAction(){ // write your own code } }
[/codesyntax]
Once you add this module in magento , login to Magento admin > Go to Sales > Invoices
Click any of the invoice to view , in the detail page you will see print , once you click that it will call your print method instead of default magento print ..
Thats it …