Shopware variant pre-selection: always show the in-stock variant first
Shopware 6 plugin that resolves the best in-stock variant across listings, search, manufacturer pages, and PDP. One service, no N+1 queries.
The Challenge
A Shopware 6 store with hundreds of variant products kept showing customers the wrong thing. A red out-of-stock variant in the listing while three colours sat on the shelf. Quote forms returning the parent product instead of the variant the customer actually clicked.
Critical Pain Points
- Listings and search showed arbitrary variants, often out of stock
- Manufacturer pages displayed parent products and broke the visual flow
- PDPs ignored merchandising preferences set through property group order
- Stock badges were wrong because cards saw individual variants without sibling context
- Quote requests resolved to parent products and pulled wrong cover images
Every product surface had its own ad-hoc variant logic. Customers saw a different "best variant" on every page. Trust drained one click at a time.
The Solution
I built one variant resolution service that every product surface routes through. One source of truth, one set of rules, one consistent answer.
One service, every surface
Listings, search, manufacturer pages, PDPs, and quote forms all call the same resolver. Whatever logic changes in one place, every surface picks it up.
Stock-aware by default
In-stock variants come first. If nothing is in stock, the first variant by position wins so the display stays predictable.
Position-aware merchandising
Property group ordering becomes a real merchandising lever. The variant with the highest priority that's also in stock wins.
Sibling stock enrichment
Listings know whether any sibling variant has stock, so card badges show real availability instead of one variant's status.
Results & Business Impact
Same product, same answer everywhere
Category listings, search results, manufacturer pages, PDP, and quote forms all show the same best variant. Customers never see two versions of the same product on one site.
Honest stock badges
Cards say in-stock when any sibling is in stock and out-of-stock only when nothing is. False alarms gone.
No N+1 query penalty
Variant resolution is batched per parent ID with DBAL queries. Performance scales with catalogue size, not with surface count.
Customer choice still wins
When a customer picks a specific variant on the PDP, the system steps aside. Pre-selection only applies before the customer chooses.
Technologies Used
- Shopware 6
- PHP 8
- Symfony
- DBAL
- Twig
- MySQL
- Event Subscribers
Variants showing the wrong product?
If your storefront resolves variants differently on every surface, customers feel the inconsistency before you do. I can fix that. Let's talk.
Book a consultationRelated Case Studies
Enterprise search plugin
Rebuilt the Findologic Search & Navigation plugin for Shopware 6 with high test coverage, GitHub Actions CI/CD, and multi-version support. Zero regressions shipped.
Read Case Study → Plugin DevelopmentMulti-platform donation plugin
Native donation plugins for Shopware 5, Shopware 6, Shopify, and WordPress with full feature parity. Built for a German charity across four platforms.
Read Case Study → B2B SolutionsIndustrial tender platform
Shopware 6 B2B tender plugin for a DACH industrial dealer. Multi-level approvals, status workflows, and a self-service dashboard. Cycle time cut from 6 weeks to 3.
Read Case Study →