/** * Load items count : * - collection size * * @return void */ private function loadItemCounts() { $storeId = $this->getStoreId(); $requestName = $this->searchRequestName; // Query text. $queryText = $this->queryText; $searchRequest = $this->requestBuilder->create($storeId, $requestName, 0, 0, $queryText, [], $this->filters, $this->queryFilters); $searchResponse = $this->searchEngine->search($searchRequest); $this->_totalRecords = $searchResponse->count(); }
/** * Load product count : * - collection size * - number of products by attribute set * * @return void */ private function loadProductCounts() { $storeId = $this->getStoreId(); $requestName = $this->searchRequestName; // Query text. $queryText = $this->queryText; $setIdFacet = ['attribute_set_id' => ['type' => BucketInterface::TYPE_TERM, 'config' => ['size' => 0]]]; $searchRequest = $this->requestBuilder->create($storeId, $requestName, 0, 0, $queryText, [], $this->filters, $this->queryFilters, $setIdFacet); $searchResponse = $this->searchEngine->search($searchRequest); $this->_totalRecords = $searchResponse->count(); $this->countByAttributeSet = []; $this->isSpellchecked = $searchRequest->isSpellchecked(); $bucket = $searchResponse->getAggregations()->getBucket('attribute_set_id'); if ($bucket) { foreach ($bucket->getValues() as $value) { $metrics = $value->getMetrics(); $this->countByAttributeSet[$metrics['value']] = $metrics['count']; } } }