File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
app/code/Magento/UrlRewriteGraphQl/Model/Resolver Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 8
8
namespace Magento \UrlRewriteGraphQl \Model \Resolver ;
9
9
10
10
use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
11
+ use Magento \Framework \GraphQl \Exception \GraphQlNoSuchEntityException ;
11
12
use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
12
13
use Magento \Framework \GraphQl \Config \Element \Field ;
13
14
use Magento \Framework \GraphQl \Query \ResolverInterface ;
@@ -73,6 +74,11 @@ public function resolve(
73
74
$ url = $ customUrl ?: $ url ;
74
75
$ urlRewrite = $ this ->findCanonicalUrl ($ url );
75
76
if ($ urlRewrite ) {
77
+ if (!$ urlRewrite ->getEntityId ()) {
78
+ throw new GraphQlNoSuchEntityException (
79
+ __ ('No such entity found with matching URL key: %url ' , ['url ' => $ url ])
80
+ );
81
+ }
76
82
$ result = [
77
83
'id ' => $ urlRewrite ->getEntityId (),
78
84
'canonical_url ' => $ urlRewrite ->getTargetPath (),
@@ -99,6 +105,9 @@ private function findCanonicalUrl(string $requestPath) : ?\Magento\UrlRewrite\Se
99
105
if (!$ urlRewrite ) {
100
106
$ urlRewrite = $ this ->findUrlFromTargetPath ($ requestPath );
101
107
}
108
+ if (!$ urlRewrite ->getEntityId () && !$ urlRewrite ->getIsAutogenerated ()) {
109
+ $ urlRewrite = $ this ->findUrlFromTargetPath ($ urlRewrite ->getTargetPath ());
110
+ }
102
111
103
112
return $ urlRewrite ;
104
113
}
You can’t perform that action at this time.
0 commit comments