New document generation extension points
INFO
This document represents an architecture decision record (ADR) and has been mirrored from the ADR section in our Shopware 6 repository. You can find the original version here
Disclaimer
This ADR does not serve as documentation (and might get outdated). The final extension points will be documented in our dev docs during implementation and maintained there. Instead, it serves as an agreed-upon approach for how these extension points should be implemented.
If you have not already, you should read 2026-03-17-refactor-of-document-generation.md and 2026-03-18-new-document-generation-architecture.md first, to understand the reasoning behind and goals of the new document generation as well as the overall architecture.
Plugin system
The plugin system can take advantage of tagged Symfony services, similar to how the core document types + formats are implemented, as well as use the Twig template extension system.
Adjusting the generated HTML / PDF / XML content and presentation
- (Optional) Add a DataProvider, which extends
AbstractDocumentDataProviderand is tagged with theshopware.documentV2.providertag to the DI container. It allows you to enrich the order with extra associations and add extra data to certain document types. - Extend the Twig templates you are interested in. You have access to all data passed into the template, including data from your own data providers, and can extend or override Twig blocks.
Adding a new document format
- (Optional) Add a DataProvider, which extends
AbstractDocumentDataProviderand is tagged with theshopware.documentV2.providertag to the DI container. It allows you to enrich the order with extra associations and add extra data to certain document types. - Add your Renderer, which extends
AbstractDocumentRendererand is tagged with theshopware.documentV2.renderertag to the DI container.- It can also make use of existing renderers' output by declaring dependencies on other formats.
Adding a new document type
- (Required) Add a DataProvider, which extends
AbstractDocumentDataProviderand is tagged with theshopware.documentV2.providertag to the DI container. It allows you to enrich the order with extra associations and add extra data for your document type. But more importantly, it allows you to register your new document type in the system, making it available for selection, e.g., in the administration. - Provide Twig templates for HTML and optionally XML to make use of our default
HtmlRendererandZugferdXmlRenderer. You can take advantage of thePdfRendereras well (which only needs HTML output), without writing any rendering code yourself besides the Twig templates.
App system
The app system can only take advantage of the Twig template extension system, which Shopware themes also use, which makes it less powerful than the plugin counterpart.
One option to add more data to a document could be to add custom fields on the order entity (e.g. via the AdminSDK or App backend and webhooks), which we load by default and apps can just use in their Twig template customizations.
Another option is to add an app script to enrich the order with extra associations and add extra render input data. The app script should allow the following:
- Enrich the order with extra associations, like the plugin system allows.
- Query extra data with repositories.
- Return arbitrary data (associative array), which will be passed to the renderers and Twig templates.
To still allow further customization, there will be additional webhooks.
Adjusting the generated HTML / PDF / XML content and presentation
- (Optional) Add custom field data to an order entity.
- (Optional) Add an app script to enrich the order with extra associations and add extra data.
- Extend the Twig templates you are interested in. You have access to all data passed into the template, including order custom fields, and you can extend or override Twig blocks.
Adding a new document type + format
- Add your desired document type and format(s) to your app manifest, so they can be selected, for example, in the admin.
- Subscribe to the webhook (document gateway, similar to the checkout gateway)
TBA. You are responsible for:- Generating the specified document type in all specified format(s) from scratch.
- Uploading the document file(s) back to Shopware.
- Having the document file(s) stored in Shopware as static documents, similar to how merchants can bypass our generation and upload documents directly.
- You have strict time constraints to perform all of the above, so your document artifacts can be used by Shopware, for example, in Flow Builder and included in customer mail.
- You have to return the generated
documentID in the webhook or gateway HTTP response.
Twig templates
Twig templates will have access to the following data:
- The
RenderInput. It includes:- Document type.
- Document number.
- Order entity including all loaded associations.
- Any extra data provided by the DataProviders.
- The usual Shopware Twig extensions. Examples include:
configfunction to look up system config values.theme_configfunction to look up theme config values.