Product properties should be inherited for variants but don't seem to load

Viewed 34

I'm using a decoration for the product repository to extend the following function by adding streams (dynamic product groups).

public function search(Criteria $criteria, SalesChannelContext $salesChannelContext): EntitySearchResult
{
    $criteria->addAssociation('streams');

    return $this->decorated->search($criteria, $salesChannelContext);
}

This doesn't seem to work with variants, even tho they're inheriting the properties none of the dynamic product groups based on those properties seem to load. The propertyIds do load for the products so the properties have been added (is default in Shopware).

1 Answers

It seems I was using a decorator for the wrong repository. I extended the SalesChannelProductRepository which means the ProductRepository doesn't change. See source below: https://stackoverflow.com/a/68232258/14184263

As long as you implement the code above within a ProductRepository decorator it works for both, as SalesChannelProductRepository inherits ProductRepository.

Edit: There does seem to be a problem with specific rules. See source below: Getting streams from product returns zero results with some rules

Related