cancel
Showing results for 
Search instead for 
Did you mean: 

Customising PDF invoices

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Customising PDF invoices

I'm migrating from Magento 1 to Magento 2, and it appears that my customised PDF invoices haven't come across.

 

I know how to use the Zend PHP framework - but I am not sure how to go about it.

In Magento 1, I copied the files in the Sales/Model/Order/PDF folder into app/code/local

rather than override the core code. Does Magento 2 work in the same way?

 

I was hoping not to just amend 

vendor/magento/module-sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php. Is there a way to keep the original files the same (so that updates will still work), while still being able to have 'my' version too?

 

2 REPLIES 2

Re: Customising PDF invoices

Hi @Avanor,

 

In Magento 2 we have a new concept: plugins

 

Also, you can use preferences to override some core (or another module) class.

The code pools don't work on M2. You should create a module and use a plugin or a preference to modify the vendor/magento/module-sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php class.

Re: Customising PDF invoices

Thanks for getting back to me.

I've had a look at the plug-ins link - it all sounds very complicated. It now appears to be very hard to do something that used to be fairly simple!

 I'm not looking to be a Magento developer as such, I just want to amend the layout of the invoice a bit.

 

Can you explain further with regards to what I need to do, with regards to using a plugin or a preference to modify the vendor/magento/module-sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php file. Thanks.