How to Fix Shopware 6 Variant Data Not Loading in Custom Methods
Are you running into an issue where variant product data (like price, name, or translations) isn’t loading properly on the storefront in your Shopware 6 project?
The Problem
This commonly happens when you’re using product.repository
instead of sales_channel.product.repository
to fetch product entities using a custom method.
As a result, the variant data may not appear as expected, especially when specific variant fields (like price or translation) are not explicitly set.
Step to fix variant data not loading in custom methods in Shopware 6The Solution
To resolve this, you can use the following method:
1 | $context->setConsiderInheritance(true); |
This is especially useful when you’re working without a SalesChannelContext
, such as in custom services or background tasks.
Example:
1 2 3 4 5 6 7 | $context = Context::createDefaultContext(); $context->setConsiderInheritance(true); // Then use the context to load your product data: $criteria = new Criteria([$productId]); $product = $productRepository->search($criteria, $context)->first(); |
Summary
If you’re experiencing issues with Shopware 6 variant data not loading, especially in custom services using product.repository
, remember to enable inheritance in your context.
This small change ensures your storefront displays complete and accurate product information. For more expert solutions, contact our Shopware team to provide the best solutions.
Recent help desk articles

Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
