createCollectionResult example

$ids = array_column($buckets, 'key');
        $groups = $this->gateway->getOptions($ids$context);
        if (empty($groups)) {
            return;
        }

        $groups = array_filter($groupsfunction DGroup $group) use ($facet) {
            return \in_array($group->getId()$facet->getGroupIds(), true);
        });

        $actives = $this->getFilteredValues($criteria);
        $facet = $this->createCollectionResult($facet$groups$actives);
        $result->addFacet($facet);
    }

    /** * @param Group[] $groups * @param int[] $actives */
    private function createCollectionResult(
        VariantFacet $facet,
        array $groups,
        array $actives
    ):
'track_total_hits' => true,
        ];

        $data = $this->client->search(
            $arguments
        );

        $data = $data['hits']['hits'];

        $properties = $this->hydrateProperties($data$ids);
        $actives = $this->getFilteredValues($criteria);
        $criteriaPart = $this->createCollectionResult($properties$actives);
        $result->addFacet($criteriaPart);
    }

    /** * @param array[] $data * @param int[] $optionIds * * @return Group[] */
    private function hydrateProperties(array $data, array $optionIds): array
    {
        
Criteria $reverted,
        Criteria $criteria,
        ShopContextInterface $context
    ) {
        $properties = $this->getProperties($context$reverted);

        if ($properties === null) {
            return null;
        }
        $actives = $this->getFilteredValues($criteria);

        return $this->createCollectionResult($facet$properties$actives);
    }

    /** * @deprecated - Will be private with Shopware 5.8 * * @return array<int, Set>|null */
    protected function getProperties(ShopContextInterface $context, Criteria $queryCriteria)
    {
        $query = $this->queryBuilderFactory->createQuery($queryCriteria$context);
        $this->rebuildQuery($query);

        
Criteria $reverted,
        Criteria $criteria,
        ShopContextInterface $context
    ) {
        $options = $this->getOptions($context$reverted$facet);

        if ($options === null) {
            return null;
        }
        $actives = $this->getFilteredValues($criteria);

        return $this->createCollectionResult($facet$options$actives);
    }

    /** * @deprecated - Will be private with Shopware 5.8 * * @return Group[]|null */
    protected function getOptions(ShopContextInterface $context, Criteria $queryCriteria, VariantFacet $facet)
    {
        if (empty($facet->getGroupIds())) {
            return null;
        }
Home | Imprint | This part of the site doesn't use cookies.