Sales channel – Verkaufskanäle – Forum-slack – 23-10-2020
Shopware 6 Sales channel – Verkaufskanäle – Forum-slack – 23-10-2020
[expand title=“mehr lesen…“]
What is the best way to create a SalesChannelContext, eg. when using a CLI command? I loaded a SalesChannelEntity and used SalesChannelContext::createFrom($loadedSalesChannelEntity), but the SalesChannelContext generated this way is missing the generic Context and doesn’t contain a setter to add one.
What is the best way to add it there?
there is a sales channel context factory service
$salesChannelContext = $this->salesChannelContextFactory->create(
Uuid::randomHex(),
$bid->getSalesChannel()->getId(),
[
SalesChannelContextService::LANGUAGE_ID => $bid->getLanguage()->getId(),
SalesChannelContextService::CUSTOMER_ID => $bid->getCustomer()->getId(),
SalesChannelContextService::COUNTRY_ID => $bid->getCustomer()->getDefaultBillingAddress()->getCountry()->getId()
]
);
[/expand]