title: How to get products from the product stream ID in Shopware 6?
body: <p>I am trying to create a custom command in which I want to utilize the Dynamic Product Group feature of Shopware 6 to fetch the products which match the filters in a specific product group (a.k.a product streams).</p>
  <p>I am doing this to fetch the streams initially, but I am lost as to how to apply the filters to fetch the products.</p>
  <pre><code>            $streamCriteria = new Criteria($productStreamIds);
              $streamCriteria-&gt;addAssociation('productCrossSellings');
              $streamCriteria-&gt;addAssociation('productExports');
              $streamCriteria-&gt;addAssociation('filters');
  
              $streams = $this-&gt;streamRepository-&gt;search($streamCriteria, $context)-&gt;getEntities();
              /** @var ProductStreamEntity $stream */
              foreach ($streams as $stream) {
                  foreach ($stream-&gt;getFilters() as $filter) {
                      $productCriteria-&gt;addAggregation($filter); // DOES NOT WORK
                      $productCriteria-&gt;addFilter($filter); // DOES NOT WORK EITHER
                  }
              }
  </code></pre>
  <p>I tried to get the <code>filters</code> which gives me the array of filters that are applied in the product stream, but it is not directly applicable to the <code>criteria-&gt;addFilter()</code> due to different expected types.</p>
  <p>This is the filters array that I get:</p>
  <pre><code>Shopware\Core\Content\ProductStream\Aggregate\ProductStreamFilter\ProductStreamFilterCollection^ {#10304
    #elements: array:5 [
      &quot;2c6a8a44d9c544f2812024f6414d56f9&quot; =&gt; Shopware\Core\Content\ProductStream\Aggregate\ProductStreamFilter\ProductStreamFilterEntity^ {#11014
        #type: &quot;multi&quot;
        #field: null
        #operator: &quot;OR&quot;
        #value: null
        #productStreamId: &quot;160274948d684a73afad0bde6aee19e8&quot;
        #parentId: null
        #productStream: null
        #queries: null
        #parent: null
        #position: 0
        #parameters: null
        #customFields: null
        #_uniqueIdentifier: &quot;2c6a8a44d9c544f2812024f6414d56f9&quot;
        #versionId: null
        #translated: []
        #createdAt: DateTimeImmutable @1600069477 {#3113
          date: 2020-09-14 07:44:37.521 UTC (+00:00)
        }
        #updatedAt: null
        #_entityName: &quot;product_stream_filter&quot;
        #extensions: array:1 [
          &quot;foreignKeys&quot; =&gt; Shopware\Core\Framework\Struct\ArrayStruct^ {#11007
            #data: []
            #apiAlias: null
            #extensions: []
          }
        ]
        #id: &quot;2c6a8a44d9c544f2812024f6414d56f9&quot;
      }
      &quot;6dff7581e91a477ea2eca564a099eb90&quot; =&gt; Shopware\Core\Content\ProductStream\Aggregate\ProductStreamFilter\ProductStreamFilterEntity^ {#10832
        #type: &quot;range&quot;
        #field: &quot;width&quot;
        #operator: null
        #value: null
        #productStreamId: &quot;160274948d684a73afad0bde6aee19e8&quot;
        #parentId: &quot;2c6a8a44d9c544f2812024f6414d56f9&quot;
        #productStream: null
        #queries: null
        #parent: null
        #position: 1
        #parameters: array:1 [
          &quot;lte&quot; =&gt; 749
        ]
        #customFields: null
        #_uniqueIdentifier: &quot;6dff7581e91a477ea2eca564a099eb90&quot;
        #versionId: null
        #translated: []
        #createdAt: DateTimeImmutable @1600069477 {#2958
          date: 2020-09-14 07:44:37.523 UTC (+00:00)
        }
        #updatedAt: null
        #_entityName: &quot;product_stream_filter&quot;
        #extensions: array:1 [
          &quot;foreignKeys&quot; =&gt; Shopware\Core\Framework\Struct\ArrayStruct^ {#10871
            #data: []
            #apiAlias: null
            #extensions: []
          }
        ]
        #id: &quot;6dff7581e91a477ea2eca564a099eb90&quot;
      }
      &quot;754b78c4ec74492bb96dc724f3e7ba6a&quot; =&gt; Shopware\Core\Content\ProductStream\Aggregate\ProductStreamFilter\ProductStreamFilterEntity^ {#10766
        #type: &quot;range&quot;
        #field: &quot;weight&quot;
        #operator: null
        #value: null
        #productStreamId: &quot;160274948d684a73afad0bde6aee19e8&quot;
        #parentId: &quot;2c6a8a44d9c544f2812024f6414d56f9&quot;
        #productStream: null
        #queries: null
        #parent: null
        #position: 2
        #parameters: array:1 [
          &quot;gte&quot; =&gt; 293
        ]
        #customFields: null
        #_uniqueIdentifier: &quot;754b78c4ec74492bb96dc724f3e7ba6a&quot;
        #versionId: null
        #translated: []
        #createdAt: DateTimeImmutable @1600069477 {#10274
          date: 2020-09-14 07:44:37.525 UTC (+00:00)
        }
        #updatedAt: null
        #_entityName: &quot;product_stream_filter&quot;
        #extensions: array:1 [
          &quot;foreignKeys&quot; =&gt; Shopware\Core\Framework\Struct\ArrayStruct^ {#10774
            #data: []
            #apiAlias: null
            #extensions: []
          }
        ]
        #id: &quot;754b78c4ec74492bb96dc724f3e7ba6a&quot;
      }
      &quot;86d2c2bd8df14f8684c8f4c801e5a19a&quot; =&gt; Shopware\Core\Content\ProductStream\Aggregate\ProductStreamFilter\ProductStreamFilterEntity^ {#10272
        #type: &quot;range&quot;
        #field: &quot;height&quot;
        #operator: null
        #value: null
        #productStreamId: &quot;160274948d684a73afad0bde6aee19e8&quot;
        #parentId: &quot;2c6a8a44d9c544f2812024f6414d56f9&quot;
        #productStream: null
        #queries: null
        #parent: null
        #position: 3
        #parameters: array:1 [
          &quot;gte&quot; =&gt; 746
        ]
        #customFields: null
        #_uniqueIdentifier: &quot;86d2c2bd8df14f8684c8f4c801e5a19a&quot;
        #versionId: null
        #translated: []
        #createdAt: DateTimeImmutable @1600069477 {#10313
          date: 2020-09-14 07:44:37.526 UTC (+00:00)
        }
        #updatedAt: null
        #_entityName: &quot;product_stream_filter&quot;
        #extensions: array:1 [
          &quot;foreignKeys&quot; =&gt; Shopware\Core\Framework\Struct\ArrayStruct^ {#11009
            #data: []
            #apiAlias: null
            #extensions: []
          }
        ]
        #id: &quot;86d2c2bd8df14f8684c8f4c801e5a19a&quot;
      }
      &quot;9b763069551244179dbc1f285290b673&quot; =&gt; Shopware\Core\Content\ProductStream\Aggregate\ProductStreamFilter\ProductStreamFilterEntity^ {#10283
        #type: &quot;equalsAny&quot;
        #field: &quot;id&quot;
        #operator: null
        #value: &quot;c01c974a89eb4f17ab78c48251864eb7|5c0e5bc5f03d42a6980c11bf8ab67428&quot;
        #productStreamId: &quot;160274948d684a73afad0bde6aee19e8&quot;
        #parentId: &quot;2c6a8a44d9c544f2812024f6414d56f9&quot;
        #productStream: null
        #queries: null
        #parent: null
        #position: 0
        #parameters: null
        #customFields: null
        #_uniqueIdentifier: &quot;9b763069551244179dbc1f285290b673&quot;
        #versionId: null
        #translated: []
        #createdAt: DateTimeImmutable @1600069477 {#12983
          date: 2020-09-14 07:44:37.522 UTC (+00:00)
        }
        #updatedAt: null
        #_entityName: &quot;product_stream_filter&quot;
        #extensions: array:1 [
          &quot;foreignKeys&quot; =&gt; Shopware\Core\Framework\Struct\ArrayStruct^ {#10356
            #data: []
            #apiAlias: null
            #extensions: []
          }
        ]
        #id: &quot;9b763069551244179dbc1f285290b673&quot;
      }
    ]
    #extensions: []
  }
  
  </code></pre>
  <p>The <code>productCrossSellings</code> and <code>productExports</code> associations are all returning <code>null</code> as well (although I do not know what is the use of these variables, but I thought maybe it is being used somehow internally to get the associated products for that group).</p>
  <p>So my question is, that how do we get the products that match the filters in a product group ?</p>