title: Filtering products via pre_get_posts by min and max price (use the product VARIATION set via default_attribute for filter results)
body: <p>I have a list of products and currently I am implementing various filter functionalities.</p>
  
  <p>Each product has 12 variations assigned to it and every variation has a different price assigned to it.</p>
  
  <p>Each product has the 'cheapest' variation defined as default (via the default attributes property of the product)</p>
  
  <p>I want to adapt the wordpress query in the <strong>pre_get_posts action</strong> to match only products <strong>between a max and a min price</strong> - <strong>however</strong>, looking at the postmeta I see that for every variation of a product there is an entry - e.g.</p>
  
  <pre><code>product_id: 10, _price: 100 (-&gt; default variation)
  product_id: 10, _price: 110
  product_id: 10, _price: 120
  product_id: 11, _price: 110 (-&gt; default variation)
  product_id: 11, _price: 120
  product_id: 11, _price: 130
  </code></pre>
  
  <p>....</p>
  
  <p>if I do something like this:</p>
  
  <pre><code>    $currentMetaQuery = $query-&gt;get('meta_query');
  
      $currentMetaQuery[] = [
          'key' =&gt; '_price',
          'value' =&gt; array($minMax['min'], $minMax['max']),
          'type' =&gt; 'numeric',
          'compare' =&gt; 'BETWEEN'
      ];
  
      $query-&gt;set('meta_query', $currentMetaQuery);
  </code></pre>
  
  <p>with a min 110 and a max of 200 I get the products with the IDs 10 and 11 (as both products contain variations which would match the filter query)</p>
  
  <p>hower:
  <strong>I want the default variations to be the base for the filtering</strong> meaning -> the query above should return only the product with the ID 11.</p>
  
  <p>So the query should actually be something like:
  <em>restrict query to products where the product's default variation has a price which is between min and max</em>...</p>
  
  <p>does anybody have an idea how to do that ?</p>
  
  <p>Thanks for any input or solutions which you could show me !</p>