<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arthur Erlich</title>
    <description>The latest articles on DEV Community by Arthur Erlich (@haylan_aeh).</description>
    <link>https://dev.to/haylan_aeh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4272369%2F67de89df-6c2e-4356-a033-8b905220e4ed.png</url>
      <title>DEV Community: Arthur Erlich</title>
      <link>https://dev.to/haylan_aeh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/haylan_aeh"/>
    <language>en</language>
    <item>
      <title>Shopware 6: Show the Main Product in Listings and on the PDP (Even with Variants)</title>
      <dc:creator>Arthur Erlich</dc:creator>
      <pubDate>Sun, 29 Nov 2026 13:42:11 +0000</pubDate>
      <link>https://dev.to/haylan_aeh/shopware-6-show-the-main-product-in-listings-and-on-the-pdp-even-with-variants-he1</link>
      <guid>https://dev.to/haylan_aeh/shopware-6-show-the-main-product-in-listings-and-on-the-pdp-even-with-variants-he1</guid>
      <description>&lt;p&gt;If you've ever fought Shopware's visibility settings, you know the pain. By default, when a product has variants, Shopware hides the main product from category listings and the product detail page (PDP) silently switches to a variant.&lt;/p&gt;

&lt;p&gt;I wanted the opposite: show the &lt;strong&gt;main product&lt;/strong&gt; in listings, load the &lt;strong&gt;main product&lt;/strong&gt; on the PDP, and list its variants inside that page. It sounded simple. Shopware's defaults made it less so.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;What I needed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only main products appear in product listings.&lt;/li&gt;
&lt;li&gt;Opening a PDP loads the main product, not a variant.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What Shopware does by default:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Main products are hidden when variants exist.&lt;/li&gt;
&lt;li&gt;PDPs automatically resolve to a "best" variant.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Changing the storefront presentation (Main product: &lt;em&gt;Everywhere&lt;/em&gt;, Variants: &lt;em&gt;Search only&lt;/em&gt;) fixes the listing, but &lt;strong&gt;not&lt;/strong&gt; the PDP. Opening the main product still loads a variant.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: hook into &lt;code&gt;ResolveVariantIdEvent&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A small plugin with an event subscriber is enough. Shopware dispatches &lt;code&gt;ResolveVariantIdEvent&lt;/code&gt; when it decides which product ID the PDP should show. Override the result and you control what loads.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductPageSubscriber&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;EventSubscriberInterface&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getSubscribedEvents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="nc"&gt;ResolveVariantIdEvent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'onResolveVariantId'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;onResolveVariantId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ResolveVariantIdEvent&lt;/span&gt; &lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setResolvedVariantId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getProductId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Register it in your plugin's &lt;code&gt;services.xml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;service&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"YourPlugin\Subscriber\ProductPageSubscriber"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tag&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"kernel.event_subscriber"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How it works
&lt;/h3&gt;

&lt;p&gt;When a main product has variants, Shopware picks a variant for the PDP. The subscriber sets the resolved ID back to the main product's own ID, so the PDP renders the parent. You can also resolve to any other product ID if your logic needs it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Storefront presentation settings only affect listings, not the PDP.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ResolveVariantIdEvent&lt;/code&gt; is a clean hook: no core files modified, no decorators needed.&lt;/li&gt;
&lt;li&gt;Tested on Shopware 6.6.10.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks to the helpful person in the Shopware community Discord who pointed me to this event. It saved me a lot of digging.&lt;/p&gt;

</description>
      <category>php</category>
      <category>shopware</category>
    </item>
  </channel>
</rss>
