From f2c024b9bd4a0b1188b62baf62b9aad647d54f28 Mon Sep 17 00:00:00 2001 From: "ryan.jehan" Date: Fri, 5 Jan 2024 10:00:33 +1030 Subject: [PATCH] Updated the helper class with constant and config logic, changed the order of the logic for product paths --- Helper/Config.php | 8 +++++--- Model/Url/GetUrlsForProducts.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Helper/Config.php b/Helper/Config.php index 85e56f7..c3d465c 100644 --- a/Helper/Config.php +++ b/Helper/Config.php @@ -4,6 +4,7 @@ */ declare(strict_types=1); + namespace Aligent\PrerenderIo\Helper; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -13,6 +14,7 @@ class Config { private const XML_PATH_RECACHE_ENABLED = 'system/prerender_io/enabled'; private const XML_PATH_PRERENDER_TOKEN = 'system/prerender_io/token'; + private const XML_PATH_PRERENDER_USE_PRODUCT_CANONICAL_URL = 'system/prerender_io/use_product_canonical_url'; /** @var ScopeConfigInterface */ private ScopeConfigInterface $scopeConfig; @@ -36,7 +38,7 @@ public function isRecacheEnabled(?int $storeId = null): bool { return $this->scopeConfig->isSetFlag( self::XML_PATH_RECACHE_ENABLED, - ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORES, $storeId ); } @@ -51,7 +53,7 @@ public function getToken(?int $storeId = null): ?string { return $this->scopeConfig->getValue( self::XML_PATH_PRERENDER_TOKEN, - ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORES, $storeId ); } @@ -66,7 +68,7 @@ public function isUseProductCanonicalUrlEnabled(?int $storeId = null): bool { return $this->scopeConfig->isSetFlag( self::XML_PATH_PRERENDER_USE_PRODUCT_CANONICAL_URL, - ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORES, $storeId ); } diff --git a/Model/Url/GetUrlsForProducts.php b/Model/Url/GetUrlsForProducts.php index 5055d79..31a3969 100644 --- a/Model/Url/GetUrlsForProducts.php +++ b/Model/Url/GetUrlsForProducts.php @@ -67,7 +67,7 @@ public function execute(array $productIds, int $storeId): array } // Ignore the product URL with category path. - if ($urlRewrite->getMetadata() && $useProductCanonical) { + if ($useProductCanonical && $urlRewrite->getMetadata()) { continue; } try {