Skip to content

Commit 9a3ab9f

Browse files
committed
Fixed 404 page on blog search page when search key is empty and custom blog route is used
1 parent d64f441 commit 9a3ab9f

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

Controller/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public function match(\Magento\Framework\App\RequestInterface $request)
287287

288288
$_identifier = trim($request->getPathInfo(), '/');
289289
$blogPage = $this->urlResolver->resolve($_identifier);
290-
if (!$blogPage || empty($blogPage['type']) || empty($blogPage['id'])) {
290+
if (!$blogPage || empty($blogPage['type']) || (empty($blogPage['id']) && $blogPage['type'] != Url::CONTROLLER_SEARCH)) {
291291
return null;
292292
}
293293

Model/UrlResolver.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,8 @@ public function resolve($path)
103103
if (!isset($pathInfo[2]) || in_array($pathInfo[2], ['index', 'feed'])) {
104104
return ['id' => 1, 'type' => Url::CONTROLLER_RSS];
105105
}
106-
} elseif ($pathInfo[1] == $this->url->getRoute(Url::CONTROLLER_SEARCH)
107-
&& !empty($pathInfo[2])
108-
) {
109-
return ['id' => $pathInfo[2], 'type' => Url::CONTROLLER_SEARCH];
106+
} elseif ($pathInfo[1] == $this->url->getRoute(Url::CONTROLLER_SEARCH)) {
107+
return ['id' => empty($pathInfo[2]) ? '' : $pathInfo[2], 'type' => Url::CONTROLLER_SEARCH];
110108
} elseif ($pathInfo[1] == $this->url->getRoute(Url::CONTROLLER_AUTHOR)
111109
&& !empty($pathInfo[2])
112110
&& ($authorId = $this->_getAuthorId($pathInfo[2]))

0 commit comments

Comments
 (0)