From 6a5914b25cebdcbbca7f76a747e9215a985e4cda Mon Sep 17 00:00:00 2001 From: magentix Date: Tue, 19 Nov 2024 14:05:33 +0100 Subject: [PATCH] AMC-483: Fix single store mode URL rewrite --- Helper/Store.php | 5 +++-- Job/Category.php | 2 +- Job/Product.php | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Helper/Store.php b/Helper/Store.php index b6be382a..9f1e7a74 100644 --- a/Helper/Store.php +++ b/Helper/Store.php @@ -79,10 +79,11 @@ public function __construct( * Retrieve all stores information * * @param string|string[] $arrayKey + * @param bool $ignoreSingleStore * * @return mixed[] */ - public function getStores($arrayKey = 'store_id') + public function getStores($arrayKey = 'store_id', bool $ignoreSingleStore = false) { if (!is_array($arrayKey)) { $arrayKey = [$arrayKey]; @@ -111,7 +112,7 @@ public function getStores($arrayKey = 'store_id') continue; } - if ($this->isSingleStoreMode() && (int)$websiteId !== 0) { + if (!$ignoreSingleStore && $this->isSingleStoreMode() && (int)$websiteId !== 0) { continue; } diff --git a/Job/Category.php b/Job/Category.php index 8d9f0bd4..50fe5a36 100755 --- a/Job/Category.php +++ b/Job/Category.php @@ -788,7 +788,7 @@ public function setUrlRewrite() /** @var string $tableName */ $tmpTable = $this->entitiesHelper->getTableName($this->jobExecutor->getCurrentJob()->getCode()); /** @var array $stores */ - $stores = $this->storeHelper->getStores('lang'); + $stores = $this->storeHelper->getStores('lang', true); /** @var mixed[] $categoryPath */ $categoryPath = $this->getCategoryPath(); /** @var mixed[] $rootCatAndStore */ diff --git a/Job/Product.php b/Job/Product.php index c759335a..c6535119 100644 --- a/Job/Product.php +++ b/Job/Product.php @@ -3669,9 +3669,9 @@ public function setUrlRewrite(): void $urlRewriteTable = $this->entitiesHelper->getTable('url_rewrite'); $productCategoriesTable = $this->entitiesHelper->getTable('catalog_category_product'); $stores = array_merge( - $this->storeHelper->getStores(['lang']), // en_US - $this->storeHelper->getStores(['lang', 'channel_code']), // en_US-channel - $this->storeHelper->getStores(['channel_code']) // channel + $this->storeHelper->getStores(['lang'], true), // en_US + $this->storeHelper->getStores(['lang', 'channel_code'], true), // en_US-channel + $this->storeHelper->getStores(['channel_code'], true) // channel ); $isUrlMapped = false; @@ -3687,7 +3687,7 @@ public function setUrlRewrite(): void // Reset stores variable to generate a column per store when nothing is mapped or url_key is global if (!$isUrlMapped) { $stores = array_merge( - $this->storeHelper->getStores(['lang']) // en_US + $this->storeHelper->getStores(['lang'], true) // en_US ); }