Skip to content

Commit 5b9ff36

Browse files
author
Roman Lytvynenko
committed
Merge branch 'MC-36117' of https://github.com/magento-tango/magento2ce into 2.3-develop
2 parents ada6d59 + 33b5b64 commit 5b9ff36

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/code/Magento/UrlRewriteGraphQl/Model/Resolver/EntityUrl.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace Magento\UrlRewriteGraphQl\Model\Resolver;
99

10+
use Magento\Framework\GraphQl\Config\Element\Field;
1011
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1112
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
12-
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
13-
use Magento\Framework\GraphQl\Config\Element\Field;
1413
use Magento\Framework\GraphQl\Query\ResolverInterface;
14+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1515
use Magento\UrlRewrite\Model\UrlFinderInterface;
1616
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
1717
use Magento\UrlRewriteGraphQl\Model\Resolver\UrlRewrite\CustomUrlLocatorInterface;
@@ -126,10 +126,16 @@ private function rewriteCustomUrls(UrlRewrite $finalUrlRewrite, int $storeId): ?
126126
* @param int $storeId
127127
* @param bool $findCustom
128128
* @return UrlRewrite|null
129+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
129130
*/
130131
private function findFinalUrl(string $requestPath, int $storeId, bool $findCustom = false): ?UrlRewrite
131132
{
132133
$urlRewrite = $this->findUrlFromRequestPath($requestPath, $storeId);
134+
if (empty($urlRewrite) && strpos($requestPath, '/') !== false) {
135+
//CMS hierarchy doesn't have their parents written into the url rewrites as they appear in hierarchy
136+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
137+
$urlRewrite = $this->findUrlFromRequestPath(basename($requestPath), $storeId);
138+
}
133139
if ($urlRewrite) {
134140
$this->redirectType = $urlRewrite->getRedirectType();
135141
while ($urlRewrite && $urlRewrite->getRedirectType() > 0) {

0 commit comments

Comments
 (0)