Shopware resources and help articles

Simple and to the point. Optimized by the community.

Load entities with translations in a different language

by Jonas Nielsen, last modified on August 26th, 2021

To load an entity (e.g. a product) with translations from another language than the current context, you'll have to construct a context for that language:

use Shopware\Core\Defaults;
use Shopware\Core\Framework\Api\Context\SystemSource;
use Shopware\Core\Framework\Context;


// This will simply use the default context and therefore use the currently active language!
$context = Context::createDefaultContext();

// Instead, create the Context yourself with the language ID / Currency ID, etc. that you wish to use, 
// i.e. one specific to a certain saleschannel
$context = new Context(
                new SystemSource(),
                [$salesChannel->getLanguageId(), Defaults::LANGUAGE_SYSTEM]

// When using this context, the DAL will pull translations and other localized content from the language you specified.
$searchResult = $this->productRepository->search($someCriteria, $context);



We use cookies to measure the performance of this website. Do you want to accept these cookies?