I want to override a method insert Totals of this file :- app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php

How can I do that? Can anyone please guide?

I saw this post : Changing PDF appearance which is quite good but still can't understand which file to make, where to make etc... We have our custom module in which we can do the stuff but I can not understand which file to make & where to put to override abstract class method.

Can anyone please guide step by step implementation of this?

Here is the further update :- What I tried is : in my config.xml file I put this :-


And I copied code/core/Mage/Sales/Model/Order/Pdf/Invoice.php in my module's folder that is code/local/Promotion/Multidiscount/Model/Sales/Order/Pdf/Invoice.php & I modified that particular function only & kept rest of the functions as it is but now this error coming when I go to Invoice of any order & click Print button.

Error :-

Fatal error: Uncaught Error: Call to a member function getPdf() on boolean in /opt/lampp/htdocs/magento_store/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php:119 Stack trace: #0 /opt/lampp/htdocs/magento_store/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php(489): Mage_Adminhtml_Controller_Sales_Invoice->printAction() #1 /opt/lampp/htdocs/magento_store/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Sales_Order_InvoiceController->printAction() #2 /opt/lampp/htdocs/magento_store/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('print') #3 /opt/lampp/htdocs/magento_store/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #4 /opt/lampp/htdocs/magento_store/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch() #5 /opt/lampp/htdocs/magento_store/app/Mage.php(683): Mage in /opt/lampp/htdocs/magento_store/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php on line 119

Url is like this :- http://localhost/magento_store/index.php/admin/sales_order_invoice/print/invoice_id/43/key/be7b6b59159f5523398350f73d1236c2/

Thank you.

  • Any guidance please? – KA9 Aug 17 '17 at 7:15

All the things were correct except one - Folder structure. I did a mistake by placing an overriding file in sales folder in model folder of my module.

I wanted to override a method insertTotals inside the following file app\code\core\Mage\Sales\Model\Order\Pdf\Abstract.php

So in my module's config file I did a change :-


But in my module, I put Invoice.php file here app\code\local\Promotion\Multidiscount\Model\Sales\Order\Pdf\Invoice.php

Actually it should be here

| improve this answer | |

Please do compare/confirm config.xml code and Invoice.php file directory structure. Following cod working for me.

open your module config.xml (example: app/code/Your/Module/etc/config.xml)

And Fine models Node then add within models node like below.


After that you need to create directory within Model directory like below


And Place Invoice.php.

Make sure you need to change class name and extend class name like below

class Your_Module_Model_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice

Hope it will work


| improve this answer | |
  • Thank you Mohammad for answering :) but I marked my answer as accepted because I found the issue & already posted here before your's :) But the important thing is that at-least I get the knowledge of how to override abstract class's method :) But thank you for answering :) – KA9 Aug 19 '17 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.