File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
Plugin/Graphql/Magento/CatalogUrlRewriteGraphQl/Model/DataProvider/UrlRewrite Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ namespace Experius \PageNotFoundGraphQl \Plugin \Graphql \Magento \CatalogUrlRewriteGraphQl \Model \DataProvider \UrlRewrite ;
5+
6+ use Magento \Catalog \Model \ProductRepository ;
7+ use Magento \Framework \Exception \NoSuchEntityException ;
8+ use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
9+
10+ class ProductDataProvider
11+ {
12+
13+ public function __construct (
14+ protected ProductRepository $ productRepository
15+ )
16+ {
17+ }
18+
19+ /**
20+ * @param \Magento\CatalogUrlRewriteGraphQl\Model\DataProvider\UrlRewrite\ProductDataProvider $subject
21+ * @param \Closure $proceed
22+ * @param string $entity_type
23+ * @param int $id
24+ * @param ResolveInfo|null $info
25+ * @param int|null $storeId
26+ * @return mixed
27+ * @throws NoSuchEntityException
28+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
29+ */
30+ public function aroundGetData (
31+ \Magento \CatalogUrlRewriteGraphQl \Model \DataProvider \UrlRewrite \ProductDataProvider $ subject ,
32+ \Closure $ proceed ,
33+ string $ entity_type ,
34+ int $ id ,
35+ ?ResolveInfo $ info = null ,
36+ ?int $ storeId = null
37+ )
38+ {
39+ $ product = $ this ->productRepository ->getById ($ id , false , $ storeId );
40+ $ result = $ product ->getData ();
41+
42+ $ result ['model ' ] = $ product ;
43+ return $ result ;
44+ }
45+ }
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" ?>
22<config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:ObjectManager/etc/config.xsd" >
3+ <type name =" Magento\CatalogUrlRewriteGraphQl\Model\DataProvider\UrlRewrite\ProductDataProvider" >
4+ <plugin name =" Experius_PageNotFoundGraphQl_Plugin_Graphql_Magento_CatalogUrlRewriteGraphQl_Model_DataProvider_UrlRewrite_ProductDataProvider" type =" Experius\PageNotFoundGraphQl\Plugin\Graphql\Magento\CatalogUrlRewriteGraphQl\Model\DataProvider\UrlRewrite\ProductDataProvider" sortOrder =" 10" disabled =" false" />
5+ </type >
36 <type name =" Magento\UrlRewriteGraphQl\Model\Resolver\Route" >
47 <plugin disabled =" false" name =" Experius_PageNotFoundGraphQl_Plugin_Graphql_Magento_UrlRewriteGraphQl_Model_Resolver_Route" sortOrder =" 999" type =" Experius\PageNotFoundGraphQl\Plugin\Graphql\Magento\UrlRewriteGraphQl\Model\Resolver\Route" />
58 </type >
Original file line number Diff line number Diff line change 44 <sequence >
55 <module name =" Magento_UrlRewriteGraphQl" />
66 <module name =" Experius_PageNotFound" />
7+ <module name =" Magento_CatalogUrlRewriteGraphQl" />
78 </sequence >
89 </module >
910</config >
You can’t perform that action at this time.
0 commit comments