Skip to content

Commit

Permalink
AMC-483: Fix single store mode URL rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
magentix committed Nov 19, 2024
1 parent c285398 commit 6a5914b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Helper/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion Job/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions Job/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
);
}

Expand Down

0 comments on commit 6a5914b

Please sign in to comment.