Skip to content

Latest commit

 

History

History
28 lines (24 loc) · 1.38 KB

2021-09-30-dont-override-language-id-of-saleschannel.md

File metadata and controls

28 lines (24 loc) · 1.38 KB
title issue
Don't override languageId of SalesChannel in SalesChannelContext
NEXT-17276

Core

  • Changed \Shopware\Core\System\SalesChannel\Context\SalesChannelContextFactory::create() to not override the languageId of the SalesChannel-Entity in the constructed SalesChannelContext.
  • Added \Shopware\Core\System\SalesChannel\SalesChannelContext::getLanguageId(), which returns the LanguageId of the underlying Core-Context.
  • Changed \Shopware\Core\System\SalesChannel\SalesChannelContext::$context to be protected instead of private, so the context is included after serialization.

Upgrade Information

LanguageId of SalesChannel in SalesChannelContext will not be overridden anymore

The languageId of the SalesChannel inside the SalesChannelContext will not be overridden by the current Language of the context anymore. So if you need the current language from the context use $salesChannelContext->getLanguageId() instead of relying on the languageId of the SalesChannel.

Before

$currentLanguageId = $salesChannelContext->getSalesChannel()->getLanguageId();

After

$currentLanguageId = $salesChannelContext->getLanguageId();

Store-Api

When calling the /store-api/context route, you now get the core context information in the response. Instead of using response.salesChannel.languageId, please use response.context.languageIdChain[0] now.