Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mass-Creation of separated invoices #336

Closed
DavidDaverl opened this issue Oct 13, 2016 · 2 comments
Closed

Mass-Creation of separated invoices #336

DavidDaverl opened this issue Oct 13, 2016 · 2 comments

Comments

@DavidDaverl
Copy link

DavidDaverl commented Oct 13, 2016

Dear Firegento-Team and other helping hands,

my tax consultant needs my invoices in separated .PDFs like invoicenumber.pdf - is this somehow possible? I only know the way to select them all in the backend and hit "PDF Rechnungen" which creates one large .PDF file with all invoices - just need to get them separated and with the invoice-number as filename.

I've tried something like

$collection = Mage::getResourceModel('sales/order_invoice_collection'); $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($this)); header("Content-type:application/pdf"); header("Content-Disposition:attachment;filename='invoices.pdf'");

which results in Fatal error: Call to a member function getStoreId() on a non-object in app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php on line 64 - so it seems there are some parameters missing.

Has anyone a solution for the whole problem or a fix for my try? Would help me very much!

Thank you in advance and best greets, David

@sprankhub
Copy link
Member

What you basically need to do is:

  1. Get your invoices (you got that one):

    $collection = Mage::getResourceModel('sales/order_invoice_collection');
    
  2. Iterate over all invoices and save them somewhere (mind the parameter of getPdf - you mixed that one up):

    $varDir = Mage::getBaseDir('var');
    foreach ($collection as $invoice) {
        $pdf      = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));
        $filename = $varDir . DS . Mage::helper('firegento_pdf')->getExportFilename('invoice', $invoice);
        $pdf->save($filename);
    }
    

This will save all invoices straight into the var folder.

@Schrank
Copy link
Member

Schrank commented Oct 14, 2016

This is a duplicate of #182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants