Homepage
Main navigation
Main content
Additional information
Login / Sign up
Quality Guidelines
Propose new content
Shopware resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
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->getCurrencyId(), [$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); ```
References
Add additional online resources to your trick
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Frontend
Administration
Performance
Indexing
SEO
Database
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline