How To Override a Method of Abstract File of Magento Invoice PDF

I’ve already given the solution to override abstract file of Magento 2 invoice PDF earlier.

Similarly, I have come up with the solution for Magento 1 as I was required to do so as a part of the client’s requirements.

We already know the importance of the attractive invoices that speaks for your brand. Adding a brand logo, signatures, etc. helps customers know who you are as a brand. And, it is important to be recognizable in the era of cutthroat competition.

And as I said in the earlier post, it is not wise to make the customizations in the default Magento invoice PDf. Because we do not want to lose our work when we upgrade to the latest Magento version.

The solution is to override abstract file of Magento invoice PDF and here’s how:

Method to override abstract file of Magento invoice PDF:

<models>
    <modulename>
        <class>NameSpace_ModuleName_Model</class>
    </modulename>
    <sales>
        <rewrite>
            <order_pdf_invoice>NameSpace_ModuleName_Model_Order_Pdf_Invoice</order_pdf_invoice>
            <order_pdf_items_invoice_default>NameSpace_ModuleName_Model_Order_Pdf_Items_Invoice_Default</order_pdf_items_invoice_default>
        </rewrite>
    </sales>
    <downloadable>
        <rewrite>
            <order_pdf_invoice>NameSpace_ModuleName_Model_Order_Pdf_Invoice</order_pdf_invoice>
            <sales_order_pdf_items_invoice>NameSpace_ModuleName_Model_Order_Pdf_Items_Invoice_Default</sales_order_pdf_items_invoice>
        </rewrite>
    </downloadable>
</models>

That’s it.

Please leave a comment below if you have any questions on the topic.

Feel free to share the solution with fellow Magento developers too!

Thanks.

Sanjay Jethva

Article by

Sanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for...