Skip to content

Commit e9bfbf3

Browse files
committed
ACP2E-2641: address CR comments
1 parent 7900047 commit e9bfbf3

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlPathGenerator.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ public function getUrlPath($category, $parentCategory = null)
8080
}
8181

8282
$path = $category->getUrlKey();
83-
if (empty($path)) {
84-
return $category->getUrlPath();
85-
}
86-
8783
if ($this->isNeedToGenerateUrlPathForParent($category)) {
8884
$parentCategory = $parentCategory === null ?
8985
$this->categoryRepository->get($category->getParentId(), $category->getStoreId()) : $parentCategory;
@@ -103,11 +99,14 @@ private function shouldReturnCurrentUrlPath(CategoryInterface $category): bool
10399
{
104100
$path = $category->getUrlPath();
105101
if ($path !== null && !$category->dataHasChangedFor('url_key') && !$category->dataHasChangedFor('parent_id')) {
106-
$parentPath = $this->getParentUrlPath($category);
102+
$parentPath = $this->generateParentUrlPathFromUrlKeys($category);
107103
if (strlen($parentPath) && str_contains($path, $parentPath) !== false) {
108104
return true;
109105
}
110106
}
107+
if (empty($category->getUrlKey())) {
108+
return true;
109+
}
111110
return false;
112111
}
113112

@@ -182,12 +181,12 @@ public function getUrlKey($category)
182181
}
183182

184183
/**
185-
* Get a parent url path based on custom scoped url keys
184+
* Generate a parent url path based on custom scoped url keys
186185
*
187186
* @param CategoryInterface $category
188187
* @return string
189188
*/
190-
private function getParentUrlPath(CategoryInterface $category): string
189+
private function generateParentUrlPathFromUrlKeys(CategoryInterface $category): string
191190
{
192191
$storeId = $category->getStoreId();
193192
$currentStore = $this->storeManager->getStore();

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ protected function setUp(): void
7777
}
7878

7979
#[
80-
DbIsolation(false),
81-
AppIsolation(false),
80+
DbIsolation(true),
81+
AppIsolation(true),
8282
DataFixtureBeforeTransaction(Website::class, as: 'website2'),
8383
DataFixtureBeforeTransaction(Group::class, ['website_id' => '$website2.id$'], as:'group2'),
8484
DataFixtureBeforeTransaction(

0 commit comments

Comments
 (0)