Zum Inhalt springen

Shopware 6 Flow Builder: Automating Business Processes Without Code

Veröffentlicht am Apr 28, 2025 | ca. 1 Min. Lesezeit |

The Flow Builder was introduced in Shopware 6.4 and replaces the old action concept. It allows shop operators to visually configure complex automations: When a specific event occurs (trigger), conditions are checked and actions are executed -- all without programming knowledge.

Core Concepts

A flow consists of:

  • Trigger: The triggering event (e.g., checkout.order.placed, customer.written)
  • Conditions (IF): Optional conditions (e.g., "Order total > 100 EUR")
  • Actions (THEN/ELSE): The actions to execute (send email, add tag, change status)

Shopware comes with many pre-built actions:

  • Send email notification
  • Change order status
  • Add or remove customer tag
  • Generate document (invoice, delivery note)
  • Trigger webhook

Custom Flow Action via Plugin

The real strength of the Flow Builder lies in the ability to register custom actions. The example: An action that sends a Slack notification when an order is received.

Action Class

<?php

declare(strict_types=1);

namespace MyPlugin\Core\Content\Flow\Action;

use Shopware\Core\Content\Flow\Dispatching\Action\FlowAction;
use Shopware\Core\Content\Flow\Dispatching\StorableFlow;
use Shopware\Core\Framework\Event\OrderAware;

class SendSlackNotificationAction extends FlowAction
{
    public static function getName(): string
    {
        return 'action.send_slack_notification';
    }

    public static function getSupportedFlowTypes(): array
    {
        return [];
    }

    public static function getSubscribedEvents(): array
    {
        return [];
    }

    public function requirements(): array
    {
        return [OrderAware::class];
    }

    public function handleFlow(StorableFlow $flow): void
    {
        $orderId = $flow->getData(OrderAware::ORDER_ID);

        if ($orderId === null) {
            return;
        }

        // Configurable parameters from the flow
        $config = $flow->getConfig();
        $webhookUrl = $config['webhookUrl'] ?? '';
        $message = $config['message'] ?? 'Neue Bestellung eingegangen!';

        if (empty($webhookUrl)) {
            return;
        }

        $this->sendSlackMessage($webhookUrl, $message, $orderId);
    }

    private function sendSlackMessage(string $webhookUrl, string $message, string $orderId): void
    {
        $payload = json_encode([
            'text' => sprintf('%s (Order ID: %s)', $message, $orderId),
        ]);

        $context = stream_context_create([
            'http' => [
                'method'  => 'POST',
                'header'  => 'Content-Type: application/json',
                'content' => $payload,
            ],
        ]);

        @file_get_contents($webhookUrl, false, $context);
    }
}

Service Registration

<service id="MyPlugin\Core\Content\Flow\Action\SendSlackNotificationAction">
    <tag name="flow.action" key="action.send_slack_notification"/>
</service>

Configuration Fields for the Admin Interface

For the Flow Builder to display an input form for the action, you need to register a custom Vue.js component in the administration bundle. There is no automatic detection of configuration fields via a PHP method — the UI is entirely controlled through an admin component.

Note: The FlowAction API was significantly refactored in Shopware 6.5. The interfaces and methods shown here should always be verified against the documentation for your target version.

Configuring Flows via API

Flows can also be created programmatically via the admin API -- useful for automated deployment or testing:

curl -X POST \
  'https://shop.example.com/api/flow' \
  -H 'Authorization: Bearer TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Slack bei Bestellung",
    "eventName": "checkout.order.placed",
    "priority": 100,
    "active": true,
    "sequences": [
      {
        "id": "seq-action-1",
        "actionName": "action.send_slack_notification",
        "config": {
          "webhookUrl": "https://hooks.slack.com/services/...",
          "message": "Neue Bestellung!"
        },
        "position": 1,
        "trueCase": true
      }
    ]
  }'

Testing Flows

Flows can be tested in the Shopware backend under Settings -> Flow Builder. For automated testing with PHPUnit:

<?php

declare(strict_types=1);

namespace MyPlugin\Tests\Core\Content\Flow;

use MyPlugin\Core\Content\Flow\Action\SendSlackNotificationAction;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Content\Flow\Dispatching\StorableFlow;
use Shopware\Core\Framework\Event\OrderAware;

class SendSlackNotificationActionTest extends TestCase
{
    public function testHandleFlowWithoutOrderId(): void
    {
        $action = new SendSlackNotificationAction();

        $flow = $this->createMock(StorableFlow::class);
        $flow->method('getData')->with(OrderAware::ORDER_ID)->willReturn(null);

        // No exception, no action when order ID is missing
        $action->handleFlow($flow);
        $this->assertTrue(true); // No error = test passed
    }

    public function testActionName(): void
    {
        $this->assertSame(
            'action.send_slack_notification',
            SendSlackNotificationAction::getName(),
        );
    }
}

Available Triggers

The most important standard triggers in Shopware 6:

Trigger Description
checkout.order.placed New order received
state_enter.order.state.completed Order completed
state_enter.order_delivery.state.shipped Shipping confirmed
customer.written Customer created or modified
newsletter.confirm Newsletter subscription confirmed
product.written Product modified

Custom triggers (events) can be registered via plugins and will then also appear in the Flow Builder.

When to Use the Flow Builder vs. a Custom Plugin?

The Flow Builder is suitable for:

  • Email notifications on status changes
  • Automatic tagging of customers or orders
  • Webhook calls to external systems
  • Document generation

When the logic is very complex, requires database access to custom tables, or multiple steps need to be coordinated, a direct event subscriber in a plugin is the better choice. The Flow Builder is not a replacement for real programming, but a complement for common, manageable automations.

Thomas Wunner

Thomas Wunner

Certified IT specialist for application development with an instructor qualification and over 14 years of experience building scalable web applications with Symfony and Shopware. When not coding, Thomas volunteers as a lifeguard with the Wasserwacht, performs as a DJ, and explores the countryside on his motorbike.

Kommentare

Kommentare werden von Remark42 bereitgestellt. Beim Laden werden Daten an unseren Kommentar-Server übertragen.