Skip to content

Commit 59c98b7

Browse files
committed
Fixes magento#25120 stores the attribute url_path for non-default Stores
1 parent d271281 commit 59c98b7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
9494
$resultUrlKey = $this->categoryUrlPathGenerator->getUrlKey($category);
9595
$this->updateUrlKey($category, $resultUrlKey);
9696
} elseif ($useDefaultAttribute) {
97-
if (!$category->isObjectNew()) {
97+
if (!$category->isObjectNew() && $category->getStoreId() === Store::DEFAULT_STORE_ID) {
9898
$resultUrlKey = $category->formatUrlKey($category->getOrigData('name'));
9999
$this->updateUrlKey($category, $resultUrlKey);
100100
}

app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ public function testShouldThrowExceptionIfUrlKeyIsEmpty($useDefaultUrlKey, $isOb
159159
$this->expectExceptionMessage('Invalid URL key');
160160
$categoryData = ['use_default' => ['url_key' => $useDefaultUrlKey], 'url_key' => '', 'url_path' => ''];
161161
$this->category->setData($categoryData);
162+
$this->category
163+
->method('getStoreId')
164+
->willReturn(\Magento\Store\Model\Store::DEFAULT_STORE_ID);
162165
$this->category->isObjectNew($isObjectNew);
163166
$this->assertEquals($isObjectNew, $this->category->isObjectNew());
164167
$this->assertEquals($categoryData['url_key'], $this->category->getUrlKey());

0 commit comments

Comments
 (0)