Category routing issue without "full category tree for product links"

Started by Dud3, January 22, 2025, 14:12:18 PM

Previous topic - Next topic

Dud3

If you disable the option "full category tree for product links" and you do not have any independant menu-entries for these categories, all of them result in a link for the joomla menu entry with category=0 and manufacturer=0.

The issue is in the router.php.
Only if self::$full is enabled, the segments array will be filled.
Otherwise it keeps beeing empty.

Here's a simple fix, didn't found any side-effects, but that whole router should be revised.
(for example multiple call of self::getCategoryRoute( $catId, $manId))


components/com_virtuemart/router.php [457]

search:
if(self::$full or !isset($query['Itemid'])){
$categoryRoute = self::getCategoryRoute( $catId, $manId);
if ($categoryRoute->route) {
$segments[] = $categoryRoute->route;
}
}

replace:
if(self::$full or !isset($query['Itemid'])){
$categoryRoute = self::getCategoryRoute( $catId, $manId);
if ($categoryRoute->route) {
$segments[] = $categoryRoute->route;
}
} elseif($catId !== 0 || $manId !== 0 || !isset($jmenu['virtuemart_category_id'][$catId][$manId])) {
$categoryRoute = self::getCategoryRoute( $catId, $manId);
if ($categoryRoute->route) {
$segments[] = $categoryRoute->route;
}
}