2

My accountant asked me an export of all my invoices at PDF (33972 invoice :/) . Is there a way to do it automatically ?

Thanks

1 Answer 1

6

You can make a quick standalone script and run the following:

$collection = Mage::getResourceModel('sales/order_invoice_collection');

$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices);

header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename='invoices.pdf'");

$pdf->render();

Although, with the number of invoices you have, I can't predict how long this is going to have run for (if it ever finishes) and how difficult this is going to be for your accountant!

2
  • it really depends on how much memory he has on his server :) I'm sure Magento will crash and won't be able to render 33972 PDFs at the same time, so I'd suggest to create some kind of queue & render invoices 1 by 1, or 100 by 100 (also depends on memory limit)
    – dsitovs
    May 11, 2015 at 17:06
  • That's a good point @dsitovs. Rendering that many invoices in one go, will crash your PHP instance, or even your browser. Queuing them (and saving the PDFs locally) is the way to go Nov 7, 2016 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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