private readonly SearchPageLoader
$searchPageLoader,
private readonly SuggestPageLoader
$suggestPageLoader,
private readonly AbstractProductSearchRoute
$productSearchRoute ) { } #[Route(path: '/search', name: 'frontend.search.page', defaults: ['_httpCache' => true], methods: ['GET'])]
public function search(SalesChannelContext
$context, Request
$request): Response
{ try { $page =
$this->searchPageLoader->
load($request,
$context);
if ($page->
getListing()->
getTotal() === 1
) { $product =
$page->
getListing()->
first();
if ($request->
get('search'
) ===
$product->
getProductNumber()) { $productId =
$product->
getId();
return $this->
forwardToRoute('frontend.detail.page',
[],
['productId' =>
$productId]);
} } } catch (RoutingException
$e) { if ($e->
getErrorCode() !== RoutingException::MISSING_REQUEST_PARAMETER_CODE
) { throw $e;
}