From 86882d9b19299e3a33037b8aacaf9638c9ad3242 Mon Sep 17 00:00:00 2001 From: Ilja Ganulevics Date: Tue, 16 Jul 2024 15:36:33 +0300 Subject: [PATCH 1/2] If query is empty set it to null --- src/Search/Request/Handler/NavigationRequestHandler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Search/Request/Handler/NavigationRequestHandler.php b/src/Search/Request/Handler/NavigationRequestHandler.php index 12f5febc..90758ee8 100644 --- a/src/Search/Request/Handler/NavigationRequestHandler.php +++ b/src/Search/Request/Handler/NavigationRequestHandler.php @@ -38,6 +38,10 @@ public function sendRequest( $this->fetchCategoryPath($request->get('navigationId'), $context), ); + if ($searchOperation->getVariables()["query"] === "") { + $searchOperation->setQuery(null); + } + return $searchOperation->execute(); } From 0231f0251e4d025c5f53273f64019e6484293809 Mon Sep 17 00:00:00 2001 From: Ilja Ganulevics Date: Tue, 16 Jul 2024 16:27:46 +0300 Subject: [PATCH 2/2] only set query to null if sort is null --- .../Handler/NavigationRequestHandler.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Search/Request/Handler/NavigationRequestHandler.php b/src/Search/Request/Handler/NavigationRequestHandler.php index 90758ee8..22615c5d 100644 --- a/src/Search/Request/Handler/NavigationRequestHandler.php +++ b/src/Search/Request/Handler/NavigationRequestHandler.php @@ -18,27 +18,29 @@ class NavigationRequestHandler extends AbstractRequestHandler { public function __construct( - ConfigProvider $configProvider, - SortingHandlerService $sortingHandlerService, - Logger $logger, + ConfigProvider $configProvider, + SortingHandlerService $sortingHandlerService, + Logger $logger, private readonly SalesChannelRepository $categoryRepository, - ) { + ) + { parent::__construct($configProvider, $sortingHandlerService, $logger); } public function sendRequest( - Request $request, - Criteria $criteria, + Request $request, + Criteria $criteria, SalesChannelContext $context, - ?int $limit = null, - ): SearchResult { + ?int $limit = null, + ): SearchResult + { $searchOperation = $this->getSearchOperation($request, $criteria, $context, $limit); $searchOperation->setCategoryPath( $this->fetchCategoryPath($request->get('navigationId'), $context), ); - if ($searchOperation->getVariables()["query"] === "") { + if ($searchOperation->getVariables()["query"] === "" && $searchOperation->getVariables()["sort"] === null) { $searchOperation->setQuery(null); } @@ -67,7 +69,7 @@ private function fetchCategoryPath(string $categoryId, SalesChannelContext $cont $categoryNames = array_map(function (string $categoryId) use ($mapping, $context, $navigationCategoryId) { return $mapping[$categoryId]; - }, array_filter($pathIds, fn ($id) => $id !== $navigationCategoryId)); + }, array_filter($pathIds, fn($id) => $id !== $navigationCategoryId)); $categoryNames[] = $withId === CategoryNamingOptions::WITH_ID ? sprintf(