File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
app/code/Magento/CatalogGraphQl/Model/Resolver/Product Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 12
12
use Magento \Framework \GraphQl \Config \Element \Field ;
13
13
use Magento \Framework \GraphQl \Query \ResolverInterface ;
14
14
use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
15
+ use Magento \Catalog \Helper \Product as ProductHelper ;
16
+ use Magento \Store \Api \Data \StoreInterface ;
15
17
16
18
/**
17
19
* Resolve data for product canonical URL
18
20
*/
19
21
class CanonicalUrl implements ResolverInterface
20
22
{
23
+ /** @var ProductHelper */
24
+ private $ productHelper ;
25
+
26
+ /**
27
+ * @param Product $productHelper
28
+ */
29
+ public function __construct (ProductHelper $ productHelper )
30
+ {
31
+ $ this ->productHelper = $ productHelper ;
32
+ }
33
+
21
34
/**
22
35
* @inheritdoc
23
36
*/
@@ -34,8 +47,11 @@ public function resolve(
34
47
35
48
/* @var $product Product */
36
49
$ product = $ value ['model ' ];
37
- $ product ->getUrlModel ()->getUrl ($ product , ['_ignore_category ' => true ]);
38
-
39
- return $ product ->getRequestPath ();
50
+ /** @var StoreInterface $store */
51
+ $ store = $ context ->getExtensionAttributes ()->getStore ();
52
+ if ($ this ->productHelper ->canUseCanonicalTag ($ store )) {
53
+ $ product ->getUrlModel ()->getUrl ($ product , ['_ignore_category ' => true ]);
54
+ return $ product ->getRequestPath ();
55
+ }
40
56
}
41
57
}
You can’t perform that action at this time.
0 commit comments