mod_virtuemart_product routing problem [j4][fix]

Started by hazael, October 17, 2022, 01:16:19 AM

Previous topic - Next topic

hazael

I noticed that this module is displaying product links incorrectly if a category is indicated that has not been added to the menu.
I can have the same product in several categories, but not all categories need to be added to the joomla menu.

If my product is in a category added to the menu and I select this category in the module, the link is displayed like this:
/category-name/product-name

If I choose a category that is not on the menu
/component/virtuemart/category-name/product-name


Currently, the only solution is to apply the canonical categories for each product, which are related to the main menu

In module after
foreach ($products as $product) {
add
if ($product->product_canon_category_id > 0) {
$cat_id = $product->product_canon_category_id;
}else{
$cat_id = $product->product_category_id;
}

find all
&virtuemart_category_id=' . $product->virtuemart_category_id);

change all to
&virtuemart_category_id=' . $cat_id);


The same problem can also occur in other modules made for virtuemart