我在 Shopware 6 的插件中构建了一个自定义订阅者,该订阅者可以订阅
\Shopware\Core\Content\Product\ProductEvents::PRODUCT_WRITTEN_EVENT = 'product.written';
public function onProductWrittenEntity(EntityWrittenEvent $event): void
{
//$event->getContext() is returning the Shopware\Core\Framework\Context
}
Run Code Online (Sandbox Code Playgroud)
我想获取当前salesChannel具有当前写入的那些productId 的域URL。我怎样才能做到这一点?
小智 5
salesChannelId您可以通过运行以下代码来获取:
$event->getContext()->getSource()->getSalesChannelId()
Run Code Online (Sandbox Code Playgroud)
这样并将viasalesChannelId插入到您的订阅者中,您就可以从该销售渠道加载所需的信息。SalesChannelRepositoryservices.xml
| 归档时间: |
|
| 查看次数: |
5878 次 |
| 最近记录: |