Skip to content

Commit 22db381

Browse files
authored
Merge pull request #21 from magento-commerce/PWA-3124
Error occurs when Runtime exception is thrown in vendor/magento/modul…
2 parents 4dd07f7 + 5258f2b commit 22db381

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Model/PageType.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Magento\UpwardConnector\Model;
1010

11+
use Magento\Framework\Exception\RuntimeException;
1112
use Magento\Store\Model\StoreManagerInterface;
1213
use Magento\UrlRewrite\Model\UrlFinderInterface;
1314
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
@@ -110,7 +111,7 @@ public function getContext(): ?Context
110111
public function resolvePageInfo(): ?array
111112
{
112113
if (!$this->getContext()) {
113-
throw new \RuntimeException('UPWARD Context not set');
114+
throw new RuntimeException(__('UPWARD Context not set'));
114115
}
115116

116117
$storeId = (int) $this->storeManager->getStore()->getId();
@@ -144,7 +145,7 @@ public function resolvePageInfo(): ?array
144145
}
145146

146147
if (empty($resultArray['id'])) {
147-
throw new \RuntimeException(
148+
throw new RuntimeException(
148149
__('No such entity found with matching URL key: %url', ['url' => $url])
149150
);
150151
}
@@ -196,11 +197,13 @@ private function findFinalUrl(string $requestPath, int $storeId, bool $findCusto
196197
$urlRewrite = $this->findUrlFromRequestPath($requestPath, $storeId);
197198
if ($urlRewrite) {
198199
$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);
201206
}
202-
} else {
203-
$urlRewrite = $this->findUrlFromTargetPath($requestPath, $storeId);
204207
}
205208
if ($urlRewrite && ($findCustom && !$urlRewrite->getEntityId() && !$urlRewrite->getIsAutogenerated())) {
206209
$urlRewrite = $this->findUrlFromTargetPath($urlRewrite->getTargetPath(), $storeId);

0 commit comments

Comments
 (0)