From 7ee9413aa1cdab0349e5184e18734c5d6fe6a91a Mon Sep 17 00:00:00 2001 From: Siarhey Uchukhlebau Date: Mon, 23 Sep 2024 19:03:14 +0300 Subject: [PATCH 1/3] Update response from custom URL Redirect with Entity data --- Plugin/ModifyRouteDataPlugin.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Plugin/ModifyRouteDataPlugin.php b/Plugin/ModifyRouteDataPlugin.php index f3e2050..d2e80c2 100644 --- a/Plugin/ModifyRouteDataPlugin.php +++ b/Plugin/ModifyRouteDataPlugin.php @@ -12,6 +12,7 @@ use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; use Magento\Framework\GraphQl\Query\Resolver\Value; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\UrlRewriteGraphQl\Model\DataProvider\EntityDataProviderComposite; use MageWorx\SeoRedirects\Model\Redirect\CustomRedirectFinder; use MageWorx\SeoRedirectsGraphQl\Model\CustomRedirectDataProviderInterface; use MageWorx\SeoRedirectsGraphQl\Model\DpRedirectDataProviderInterface; @@ -21,15 +22,18 @@ class ModifyRouteDataPlugin protected DpRedirectDataProviderInterface $dpRedirectDataProvider; protected CustomRedirectDataProviderInterface $customRedirectDataProvider; protected CustomRedirectFinder $customRedirectFinder; + protected EntityDataProviderComposite $entityDataProviderComposite; public function __construct( DpRedirectDataProviderInterface $dpRedirectDataProvider, CustomRedirectDataProviderInterface $customRedirectDataProvider, - CustomRedirectFinder $customRedirectFinder + CustomRedirectFinder $customRedirectFinder, + EntityDataProviderComposite $entityDataProviderComposite ) { $this->dpRedirectDataProvider = $dpRedirectDataProvider; $this->customRedirectDataProvider = $customRedirectDataProvider; $this->customRedirectFinder = $customRedirectFinder; + $this->entityDataProviderComposite = $entityDataProviderComposite; } /** @@ -92,6 +96,15 @@ public function afterResolve( } $urlRewriteData = $this->customRedirectDataProvider->getEntityUrlDataByCustomRedirectEntity($customRedirect); + if (is_array($urlRewriteData) && !empty($urlRewriteData['type']) && !empty($urlRewriteData['id'])) { + $entityData = $this->entityDataProviderComposite->getData( + $urlRewriteData['type'], + (int)$urlRewriteData['id'], + $info, + $storeId + ); + $urlRewriteData += $entityData; + } return empty($urlRewriteData) ? null : $urlRewriteData; } From 32a0ad9e473c8f1f6e2817b36238b4e6b9daf6f4 Mon Sep 17 00:00:00 2001 From: Siarhey Uchukhlebau Date: Wed, 2 Oct 2024 16:56:21 +0300 Subject: [PATCH 2/3] Make entity data from data provider more prioritised in result array --- Plugin/ModifyRouteDataPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugin/ModifyRouteDataPlugin.php b/Plugin/ModifyRouteDataPlugin.php index d2e80c2..eaa103d 100644 --- a/Plugin/ModifyRouteDataPlugin.php +++ b/Plugin/ModifyRouteDataPlugin.php @@ -103,7 +103,7 @@ public function afterResolve( $info, $storeId ); - $urlRewriteData += $entityData; + $urlRewriteData = $entityData + $urlRewriteData;; } return empty($urlRewriteData) ? null : $urlRewriteData; From b1da3c3b7b1d8760dc62738458da795e693574cb Mon Sep 17 00:00:00 2001 From: Siarhey Uchukhlebau Date: Fri, 8 Nov 2024 13:44:39 +0300 Subject: [PATCH 3/3] v1.3.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cff0cc6..da20e0d 100755 --- a/composer.json +++ b/composer.json @@ -19,5 +19,5 @@ "MageWorx\\SeoRedirectsGraphQl\\": "" } }, - "version": "1.3.2" + "version": "1.3.3" }