Preselect correct Sales Channel mail template in "Send Document" modal
Summary
When manually sending a document (e.g. an invoice) from the order detail page in the Shopware 6 Administration, the "Send Document" modal always preselects the first globally available mail template of the matching type — regardless of which Sales Channel the order belongs to.
If multiple mail templates of the same type (e.g. "Invoice / Rechnung") exist for different Sales Channels, the administrator must manually select the correct template every time. This is error-prone and leads to customers potentially receiving emails styled for the wrong Sales Channel (wrong branding, wrong logo, wrong sender identity).
Current Behavior
The sw-order-send-document-modal component preselects the first available mail template of the matching type, without considering the Sales Channel of the current order.
Example:
Order belongs to Sales Channel pizza1.de
Available templates of type "Invoice": MotorGarten - Rechnung ✓ (preselected), pizza1.de - Rechnung, Rechnung ebay Template
The modal preselects MotorGarten - Rechnung instead of pizza1.de - Rechnung
Expected Behavior
The modal should automatically preselect the mail template that is assigned to (or best matches) the Sales Channel of the order being processed.
Fallback logic suggestion:
Prefer a template explicitly assigned to the order's Sales Channel
Fall back to the global/default template if no Sales Channel-specific template exists
Why This Matters
Shops operating multiple Sales Channels (e.g. different storefronts or marketplaces) typically maintain separate mail templates per channel for branding and legal reasons. The current behavior forces staff to manually pick the right template on every document send — and a wrong selection means the customer receives an email with the wrong branding.
Suggested Implementation
In sw-order-send-document-modal/index.js, when loading and defaulting the mail template selection, filter or sort templates by the salesChannelId of the current order and preselect the best match.
Relevant file:
src/Administration/Resources/app/administration/src/module/sw-order/component/sw-order-send-document-modal/index.js
Environment
Shopware Version: 6.x (reproducible across versions)
Multiple Sales Channels with separate mail templates of the same type