Shopware 6.7.15+ Bug: Resolving Missing Sales Channel in Flow-Triggered Emails

Shopware 6.7.15+ Bug: Resolving Missing Sales Channel in Flow-Triggered Emails

A significant issue has emerged in Shopware versions 6.7.15 and newer, affecting stores that utilize the new 'Dokument-Erzeugung-Abgeschlossen' (Document Generation Completed) Flow Builder trigger for automated email dispatches. Users are reporting that when an email is sent via this new trigger, the salesChannel object within the email context is unexpectedly NULL. This prevents critical information like the shop's name, custom headers, footers, and channel-specific URLs from being rendered correctly, leading to Twig rendering errors such as:

{ "source": "core", "environment": "dev", "additionalData": { "message": "Could not render Mail-SenderName with error message: Failed rendering string template using Twig: Impossible to access an attribute ("name") on a null variable in "72d8769ea77caa606f46f95626407b3f" at line 1.", "template": "{{ salesChannel.name }}", "eventName": "document.generation.completed", "exception": "Shopware\Core\Framework\Adapter\AdapterException: Failed rendering string template using Twig: Impossible to access an attribute ("name") on a null variable in "72d8769ea77caa606f46f95626407b3f" at line 1 }

This error specifically highlights the inability to access the name attribute on a null salesChannel variable, indicating a core issue in how the event context is populated.

The Root Cause: A Confirmed Bug

Community experts have confirmed this to be a bug in Shopware 6.7.15.1 and even in the current development branch. The underlying problem lies with the DocumentGeneratedEvent, which is triggered by document.generation.completed. This event consistently returns null for getSalesChannelId(). Consequently, the Flow Builder inherits this null value for the email dispatch, failing to retrieve the correct sales channel associated with the order, even when the order itself has been loaded.

As of the discussion, no official issue has been found on GitHub, and users are encouraged to report it via the Shopware GitHub Issues page using the 'Bug report' template.

Immediate Workarounds for Merchants (No Programming Required)

Until an official fix is released, several non-programmatic workarounds can be applied, especially if your emails can afford to look identical across all sales channels or if you operate a single sales channel:

  1. Hardcode Sender Name: In the email template used by the Flow, replace {{ salesChannel.name }} in the 'Sender' field with your shop's name as plain text.
  2. Manually Embed Header and Footer: Shopware only attaches global headers and footers if a sales channel is known. Copy the HTML content directly from 'Settings → E-Mail-Templates', 'Kopf- und Fußzeilen' (Header and Footer) tab, and paste it at the beginning and end of your specific email template. Ensure any salesChannel variables within this copied content are also replaced with fixed text.
  3. Review Other Variables: While the order object is available, salesChannel is not. For instance, if your invoice templates use salesChannel.domains|first.url for accessibility links, these must be replaced with your shop's fixed URL.
  4. Control Sender Address: Without a sales channel, Shopware defaults to the address configured in the global basic settings. Any sales channel-specific sender addresses will not be applied.

Alternative Flow Setup for Automated Document Generation

If your documents are generated automatically (e.g., upon an order status change), you can revert to a previously working method within the Flow Builder:

  • Instead of relying solely on the 'Document Generation Completed' trigger for email dispatch, configure your Flow to first 'Generate Documents' based on an order trigger (e.g., 'Order status changed'), and then 'Send Email' with the specific document type attached. In this scenario, the email context correctly identifies the order's sales channel.

Developer-Level Solution for Multi-Channel Stores

For stores with multiple sales channels requiring distinct sender details or footers, a programmatic solution is necessary. As suggested by community members, developers can implement a subscriber that listens to the FlowSendMailActionEvent. Within this event, the salesChannelId of the order can be explicitly set, allowing the email templates to function as intended without modification.

This comprehensive approach ensures that merchants and developers can mitigate the impact of this bug, maintaining proper email communication while awaiting an official Shopware patch.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools