addGrouping example

 {
    }

    /** * @return EntitySearchResult<ProductCollection> */
    public function load(Criteria $origin, SalesChannelContext $context): EntitySearchResult
    {
        $origin->addState(Criteria::STATE_ELASTICSEARCH_AWARE);
        $criteria = clone $origin;

        $this->addGrouping($criteria);
        $this->handleAvailableStock($criteria$context);

        $ids = $this->productRepository->searchIds($criteria$context);
        /** @var list<string> $keys */
        $keys = $ids->getIds();
        $aggregations = $this->productRepository->aggregate($criteria$context);

        // no products found, no need to continue         if (empty($keys)) {
            return new EntitySearchResult(
                ProductDefinition::ENTITY_NAME,
                
Home | Imprint | This part of the site doesn't use cookies.