ProductNumberSearchResult example

$arguments = [
            'index' => $index->getName(),
            'body' => $search->toArray(),
            'rest_total_hits_as_int' => true,
            'track_total_hits' => true,
        ];

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

        $products = $this->createProducts($data);

        $result = new ProductNumberSearchResult(
            $products,
            $data['hits']['total'],
            []
        );

        if (isset($data['hits']['max_score'])) {
            $result->addAttribute('elastic_search', new Attribute(['max_score' => $data['hits']['max_score']]));
        }

        foreach ($this->handlerRegistry->getHandlers() as $handler) {
            if (!($handler instanceof ResultHydratorInterface)) {
                
$query = $this->queryBuilderFactory->createProductQuery($criteria$context);

        $products = $this->getProducts($query);

        $total = \count($products);
        if ($criteria->fetchCount()) {
            $total = $this->getTotalCount($query);
        }

        $facets = $this->createFacets($criteria$context);

        return new SearchBundle\ProductNumberSearchResult($products(int) $total$facets);
    }

    /** * @return array */
    private function getProducts(QueryBuilder $query)
    {
        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
        $products = [];

        foreach ($data as $row) {
            
Home | Imprint | This part of the site doesn't use cookies.