首页 > 解决方案 > Sylius:自定义命令中未找到频道

问题描述

在自定义命令中使用默认 SyliusCompositeChannelContext会出错,找不到该频道。

  [Sylius\Component\Channel\Context\ChannelNotFoundException]                                                    
  Channel could not be found! Tip: You can use the Web Debug Toolbar to switch between channels in development. 

在 Profiler 中更改它并没有什么不同。

我应该如何在 Command 中使用 ChannelContext?

标签: sylius

解决方案


创建具有低优先级的 CustomChannelContext 允许我绕过此错误。现在,每当调用 CompositeChannelContext 时,它最后都会通过我的 CustomChannelContext 并获取存储库中的最后一个通道。


推荐阅读