Skip to content

Commit

Permalink
counts of found products are not displayed for Luigi's Box in autocom…
Browse files Browse the repository at this point in the history
…plete but are kept on search page
  • Loading branch information
TomasLudvik committed Mar 28, 2024
1 parent d42f640 commit c2c1f48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Model/Batch/LuigisBoxBatchLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,18 @@ public function loadByBatchData(array $luigisBoxBatchLoadData): Promise
$mainBatchLoadData->getFacetNames(),
),
$limitsByType,
$mainBatchLoadData->getEndpoint(),
),
);
}

/**
* @param \Shopsys\LuigisBoxBundle\Component\LuigisBox\LuigisBoxResult[] $luigisBoxResults
* @param array $limitsByType
* @param string $endpoint
* @return array
*/
protected function mapDataByTypes(array $luigisBoxResults, array $limitsByType): array
protected function mapDataByTypes(array $luigisBoxResults, array $limitsByType, string $endpoint): array
{
$mappedData = [];

Expand All @@ -126,14 +128,13 @@ protected function mapDataByTypes(array $luigisBoxResults, array $limitsByType):
$mappedDataOfCurrentType = $this->mapBrandData($luigisBoxResults[$type]);
}

if ($type === $this->getMainType()) {
if ($endpoint === LuigisBoxClient::ACTION_SEARCH && $type === $this->getMainType()) {
static::$facets = $luigisBoxResults[$type]->getFacets();
static::$totalsByType[$type] = $luigisBoxResults[$type]->getItemsCount();
} else {
static::$totalsByType[$type] = -1;
}

static::$totalsByType[$type] = count($mappedDataOfCurrentType);
$mappedData[] = $mappedDataOfCurrentType;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Model/Category/CategoriesSearchResultsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function ($offset, $limit) use ($argument) {
/** @var \GraphQL\Executor\Promise\Promise $promise */
$promise = $paginator->auto($argument, 0);

$promise->then(function ($productConnection) {
$productConnection->setTotalCount(LuigisBoxBatchLoader::getTotalByType(LuigisBoxClient::TYPE_IN_LUIGIS_BOX_CATEGORY));
$promise->then(function (ConnectionInterface $connection) {
$connection->setTotalCount(LuigisBoxBatchLoader::getTotalByType(LuigisBoxClient::TYPE_IN_LUIGIS_BOX_CATEGORY));
});

return $promise;
Expand Down

0 comments on commit c2c1f48

Please sign in to comment.