SumResult example

case $aggregation instanceof EntityAggregation:
                return $this->hydrateEntityAggregation($aggregation$result$context);

            case $aggregation instanceof MaxAggregation:
                return new MaxResult($aggregation->getName()$result['value']);

            case $aggregation instanceof MinAggregation:
                return new MinResult($aggregation->getName()$result['value']);

            case $aggregation instanceof SumAggregation:
                return new SumResult($aggregation->getName()$result['value']);

            case $aggregation instanceof FilterAggregation:
                $nested = $aggregation->getAggregation();

                if (!$nested) {
                    throw new \RuntimeException(sprintf('Filter aggregation %s contains no nested aggregation.', $aggregation->getName()));
                }
                $nestedResult = $result;

                while (isset($nestedResult[$aggregation->getName()])) {
                    $nestedResult = $nestedResult[$aggregation->getName()];
                }
static::expectException(PageNotFoundException::class);

        $this->controller->category($ids->get('category')new Request()$this->createMock(SalesChannelContext::class));
    }

    public function testFilterReturn(): void
    {
        $ids = new IdsCollection();

        $testAggregations = new \ArrayObject([
            'count' => new CountResult('count', 2),
            'sum' => new SumResult('sum', 2.3),
        ]);
        $productListingResultMock = $this->createMock(ProductListingResult::class);
        $productListingResultMock->method('getAggregations')->willReturn(
            new AggregationResultCollection(
                $testAggregations
            )
        );

        $request = new Request();

        $productListingRouteResponse = new ProductListingRouteResponse($productListingResultMock);
        
return $this->hydrateResult($aggregationStruct$definition$rows$context);

            case $aggregation instanceof AvgAggregation:
                $value = isset($rows[0]) ? $rows[0][$name] : 0;

                return new AvgResult($aggregation->getName()(float) $value);

            case $aggregation instanceof SumAggregation:
                $value = isset($rows[0]) ? $rows[0][$name] : 0;

                return new SumResult($aggregation->getName()(float) $value);

            case $aggregation instanceof MaxAggregation:
                $value = isset($rows[0]) ? $rows[0][$name] : 0;

                return new MaxResult($aggregation->getName()$value);

            case $aggregation instanceof MinAggregation:
                $value = isset($rows[0]) ? $rows[0][$name] : 0;

                return new MinResult($aggregation->getName()$value);

            
Home | Imprint | This part of the site doesn't use cookies.