providerCheapestPriceAggregation example

$criteria = new Criteria(array_values($affected));
            $criteria->addState(Criteria::STATE_ELASTICSEARCH_AWARE);
            $criteria->addFilter(new OrFilter([
                new NandFilter([new EqualsFilter('product.parentId', null)]),
                new EqualsFilter('product.childCount', 0),
            ]));

            $criteria->addAggregation(new StatsAggregation('price', 'product.cheapestPrice'));

            $aggregator = $this->createEntityAggregator();

            $cases = $this->providerCheapestPriceAggregation();

            foreach ($cases as $message => $case) {
                $context->setRuleIds($ids->getList($case['rules']));

                $result = $aggregator->aggregate($this->productDefinition, $criteria$context);

                $aggregation = $result->get('price');

                static::assertInstanceOf(StatsResult::class$aggregation);
                static::assertEquals($case['min']$aggregation->getMin()sprintf('Case `%s` failed', $message));
                static::assertEquals($case['max']$aggregation->getMax()sprintf('Case `%s` failed', $message));
            }
Home | Imprint | This part of the site doesn't use cookies.