|
7 | 7 |
|
8 | 8 | namespace Magento\UrlRewriteGraphQl\Model\Resolver;
|
9 | 9 |
|
| 10 | +use Magento\Framework\GraphQl\Config\Element\Field; |
10 | 11 | use Magento\Framework\GraphQl\Exception\GraphQlInputException;
|
11 | 12 | use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
|
12 |
| -use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; |
13 |
| -use Magento\Framework\GraphQl\Config\Element\Field; |
14 | 13 | use Magento\Framework\GraphQl\Query\ResolverInterface;
|
| 14 | +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; |
15 | 15 | use Magento\UrlRewrite\Model\UrlFinderInterface;
|
16 | 16 | use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
|
17 | 17 | use Magento\UrlRewriteGraphQl\Model\Resolver\UrlRewrite\CustomUrlLocatorInterface;
|
@@ -126,10 +126,16 @@ private function rewriteCustomUrls(UrlRewrite $finalUrlRewrite, int $storeId): ?
|
126 | 126 | * @param int $storeId
|
127 | 127 | * @param bool $findCustom
|
128 | 128 | * @return UrlRewrite|null
|
| 129 | + * @SuppressWarnings(PHPMD.CyclomaticComplexity) |
129 | 130 | */
|
130 | 131 | private function findFinalUrl(string $requestPath, int $storeId, bool $findCustom = false): ?UrlRewrite
|
131 | 132 | {
|
132 | 133 | $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 | + } |
133 | 139 | if ($urlRewrite) {
|
134 | 140 | $this->redirectType = $urlRewrite->getRedirectType();
|
135 | 141 | while ($urlRewrite && $urlRewrite->getRedirectType() > 0) {
|
|
0 commit comments