Document Storage, Email and Downloads
Generation creates the document content. Storage and delivery decide what happens next. Configure these separately so that a valid file is not lost, attached twice or mistaken for a transmitted invoice.
What each format produces
| Format | XML | Hybrid PDF | Automatic attachment choice |
|---|---|---|---|
| ZUGFeRD | Yes | Yes | |
| Factur-X | Yes | Yes | |
| XRechnung | Yes | No | XML |
| EN 16931 | Yes | No | XML |
| PEPPOL BIS Billing 3.0 | Yes | No | XML |
The Automatic attachment strategy sends the hybrid PDF when one exists; otherwise it sends XML. XML only, PDF only and Both let you override that choice. Selecting PDF-only for an XML-only format leaves no PDF to attach.
Permanent storage
With Permanent Storage, generated files are written below Magento's private var/ directory, at the path configured in File Storage Path (default einvoice). The default locations are:
var/einvoice/
var/einvoice/creditmemo/
The invoice or credit memo stores the format, status, generation time and relative XML/PDF paths. Admin downloads, API enrichment and customer downloads can reuse those files. Because the files live outside pub/media, they are never reachable through a public URL — downloads run through controlled admin and customer-account actions.
Use permanent storage when you want predictable downloads, backup coverage and a stable hand-off to another system. Treat the directory as invoice data: include it in retention planning. To move artifacts written by older module versions from pub/media into private storage, run php bin/magento einvoice:storage:migrate-public.
On-demand generation
With On-Demand Generation, the file manager does not persist XML or PDF during normal generation. When a supported action later asks for the document, the service can generate it again from the Magento invoice or credit memo.
This reduces stored files but changes the operational risk:
- a later configuration or source-data change can affect regenerated output;
- downloads and emails do more work at request time;
- the original generated bytes are not preserved as an archive;
- generation must still be enabled and healthy when the file is requested.
Choose on-demand only when those trade-offs fit your accounting and retention process.
Filename patterns
Invoice patterns can use:
{invoice_increment_id}{order_increment_id}{invoice_id}{format}{type}{date}{datetime}
Credit-memo patterns use the corresponding credit-memo and order identifiers documented in the configuration screen. Path separators and unsafe filename characters are removed by the storage service.
Use a stable, readable pattern. Do not put customer names, email addresses or other personal data in filenames.
Email attachments
Invoice and credit-memo email attachments have separate enable switches and strategies. The sender plugin looks up or generates the document immediately before the Magento email is sent, registers the chosen attachments, sends the message and then clears the temporary registry.
For a safe rollout:
- keep attachments disabled while validating files;
- configure the invoice attachment switch and strategy without changing the credit-memo switch;
- send an invoice email to a reserved
.exampleaddress captured by local Mailpit; - inspect the Mailpit message, filename, MIME type and actual attachment contents;
- repeat with the separate credit-memo attachment switch and a new credit-memo email;
- confirm how async generation interacts with the moment each email is sent;
- record this as local Mailpit evidence, not real recipient delivery.
If queue or cron generation happens after the transactional email, the document may not yet be available. Align email timing with the selected generation mode.
Customer downloads
The customer account can offer downloads for generated documents. Five switches under Customer Account Downloads control the offer — all are disabled by default and must be enabled per store view:
- Invoice XML, Invoice PDF and Invoice XML ZIP on the invoice page;
- Credit Memo XML and Credit Memo PDF on the credit-memo page.
PDF downloads apply to hybrid formats (ZUGFeRD, Factur-X); XML-only formats produce XML downloads. The ZIP action bundles all of an order's generated invoice XML files into one archive.
The controllers check document ownership and availability before returning a file. Guest and registered-customer layouts are supported.
What this does not deliver
Saving a PEPPOL BIS XML file does not send it through PEPPOL. Creating XRechnung XML does not upload it to a public-sector portal. Connect the stored or on-demand output to the delivery service required by the recipient.