|
8 | 8 |
|
9 | 9 | namespace Magento\UpwardConnector\Model; |
10 | 10 |
|
| 11 | +use Magento\Framework\Exception\RuntimeException; |
11 | 12 | use Magento\Store\Model\StoreManagerInterface; |
12 | 13 | use Magento\UrlRewrite\Model\UrlFinderInterface; |
13 | 14 | use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; |
@@ -110,7 +111,7 @@ public function getContext(): ?Context |
110 | 111 | public function resolvePageInfo(): ?array |
111 | 112 | { |
112 | 113 | if (!$this->getContext()) { |
113 | | - throw new \RuntimeException('UPWARD Context not set'); |
| 114 | + throw new RuntimeException(__('UPWARD Context not set')); |
114 | 115 | } |
115 | 116 |
|
116 | 117 | $storeId = (int) $this->storeManager->getStore()->getId(); |
@@ -144,7 +145,7 @@ public function resolvePageInfo(): ?array |
144 | 145 | } |
145 | 146 |
|
146 | 147 | if (empty($resultArray['id'])) { |
147 | | - throw new \RuntimeException( |
| 148 | + throw new RuntimeException( |
148 | 149 | __('No such entity found with matching URL key: %url', ['url' => $url]) |
149 | 150 | ); |
150 | 151 | } |
@@ -196,11 +197,13 @@ private function findFinalUrl(string $requestPath, int $storeId, bool $findCusto |
196 | 197 | $urlRewrite = $this->findUrlFromRequestPath($requestPath, $storeId); |
197 | 198 | if ($urlRewrite) { |
198 | 199 | $this->redirectType = $urlRewrite->getRedirectType(); |
199 | | - while ($urlRewrite && $urlRewrite->getRedirectType() > 0) { |
200 | | - $urlRewrite = $this->findUrlFromRequestPath($urlRewrite->getTargetPath(), $storeId); |
| 200 | + if($urlRewrite->getRedirectType() > 0) { |
| 201 | + while ($urlRewrite && $urlRewrite->getRedirectType() > 0) { |
| 202 | + $urlRewrite = $this->findUrlFromRequestPath($urlRewrite->getTargetPath(), $storeId); |
| 203 | + } |
| 204 | + } else { |
| 205 | + $urlRewrite = $this->findUrlFromTargetPath($requestPath, $storeId); |
201 | 206 | } |
202 | | - } else { |
203 | | - $urlRewrite = $this->findUrlFromTargetPath($requestPath, $storeId); |
204 | 207 | } |
205 | 208 | if ($urlRewrite && ($findCustom && !$urlRewrite->getEntityId() && !$urlRewrite->getIsAutogenerated())) { |
206 | 209 | $urlRewrite = $this->findUrlFromTargetPath($urlRewrite->getTargetPath(), $storeId); |
|
0 commit comments