Skip to content

Commit 7876d24

Browse files
committed
WIP: [VirtualCategories] Fixes #3055 ... / replicate on product URLs
1 parent ad8fd21 commit 7876d24

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • src/module-elasticsuite-virtual-category/Model

src/module-elasticsuite-virtual-category/Model/Url.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,19 @@ public function getProductRewrite($productRequestPath, $categoryRequestPath, $st
140140
if (!$this->virtualCategoryRoot->getAppliedRootCategory()) {
141141
$categoryId = $this->getVirtualCategoryIdByPath($categoryRequestPath);
142142
} else {
143+
$categoryUrlPath = $categoryRequestPath;
144+
$appliedRoot = $this->virtualCategoryRoot->getAppliedRootCategory();
145+
$appliedRootUrlPath = $appliedRoot->getUrlPath();
146+
if (!empty($appliedRootUrlPath) && (strpos($categoryRequestPath, $appliedRootUrlPath) === 0)) {
147+
$categoryUrlPath = str_replace($appliedRootUrlPath, '', $categoryRequestPath);
148+
$categoryUrlPath = ltrim($categoryUrlPath, '/');
149+
}
150+
/*
143151
$urlKeys = explode('/', $categoryRequestPath);
144152
$urlKey = array_pop($urlKeys);
145153
$category = $this->loadCategoryByUrlKey($urlKey);
154+
*/
155+
$category = $this->loadCategoryByUrlPath($categoryUrlPath);
146156
$categoryId = $category->getId();
147157
}
148158
if ($categoryId) {

0 commit comments

Comments
 (0)