Shopware 6: How to NOT trigger flows
Fabian Blechschmidt
Thanks to Melvin Achterhuis I learned last week, that there is a context state to avoid triggering flows. But you can not only add it to your API request as sw-skip-trigger-flow
, but you can use it in your code as well.
$context->addState(Context::SKIP_TRIGGER_FLOW);
Shopware Slack, Melvin Achterhuis
I didn’t test anything of this!
But as you can see for example in \Shopware\Core\Content\ImportExport\ImportExport::import
, you can use this state for your own code as well. Simply add it to the context:
$context->addState(Context::SKIP_TRIGGER_FLOW);
Two things to consider:
- Make sure you do it early enough. If the mail is already sent, no state will help you.
- It seems that sometimes context changes, e.g. in
\Shopware\Core\Checkout\Cart\Order\OrderConverter::assembleSalesChannelContext
one can find this diamond:
if ($context->hasState(Context::SKIP_TRIGGER_FLOW)) {
? $salesChannelContext->getContext()->addState(Context::SKIP_TRIGGER_FLOW);
}
So make sure, that you add it to the correct context.
And don’t forget:
Also need to remove the state if u just want to skip one or certain flows
Shopware Slack, No.999
Other articles from this category