diff --git a/src/Decorator/Core/Content/Product/SalesChannel/Listing/ProductListingRoute.php b/src/Decorator/Core/Content/Product/SalesChannel/Listing/ProductListingRoute.php index 8c5ea5ae..2c4ea000 100644 --- a/src/Decorator/Core/Content/Product/SalesChannel/Listing/ProductListingRoute.php +++ b/src/Decorator/Core/Content/Product/SalesChannel/Listing/ProductListingRoute.php @@ -50,6 +50,10 @@ public function load( SalesChannelContext $context, Criteria $criteria = null, ): ProductListingRouteResponse { + $originalRequest = clone $request; + $originalContext = clone $context; + $originalCriteria = clone $criteria; + $shouldHandleRequest = SearchHelper::shouldHandleRequest($context, $this->configProvider, true); $isDefaultCategory = $categoryId === $context->getSalesChannel()->getNavigationCategoryId(); @@ -79,6 +83,11 @@ public function load( $productListing = ProductListingResult::createFrom( $this->fetchProductsById($criteria, $context), ); + + if (!$productListing->getElements()) { + return $this->decorated->load($categoryId, $originalRequest, $originalContext, $originalCriteria); + } + $productListing->addCurrentFilter('navigationId', $categoryId); $productListing->setStreamId($streamId); diff --git a/src/Decorator/Core/Content/Product/SalesChannel/Search/ProductSearchRoute.php b/src/Decorator/Core/Content/Product/SalesChannel/Search/ProductSearchRoute.php index 80e1447e..d402e19d 100644 --- a/src/Decorator/Core/Content/Product/SalesChannel/Search/ProductSearchRoute.php +++ b/src/Decorator/Core/Content/Product/SalesChannel/Search/ProductSearchRoute.php @@ -56,6 +56,10 @@ public function load( Criteria $criteria, ): ProductSearchRouteResponse { try { + $originalRequest = clone $request; + $originalContext = clone $context; + $originalCriteria = clone $criteria; + if (!SearchHelper::shouldHandleRequest($context, $this->configProvider)) { return $this->decorated->load($request, $context, $criteria); } @@ -83,6 +87,11 @@ public function load( $query = $request->query->get('search'); $result = $this->fetchProductsById($criteria, $context, $query); + + if (!$result->getElements()) { + return $this->decorated->load($originalRequest, $originalContext, $originalCriteria); + } + $productListing = ProductListingResult::createFrom($result); $productListing->addCurrentFilter('search', $query);