News:

Support the VirtueMart project and become a member

Main Menu

Uri parse with category ID

Started by sbou, December 16, 2021, 16:05:19 PM

Previous topic - Next topic

sbou

Hi,

I was helping a user who have problem on switching with Falang on the same product to another language.
It was working before without problem.

The user don't use id for category and product. from a category page when you click on the product all work fine but the language switcher don't build the right url.

The problem is during the parse of the url, the category is not set in the vars (virtuemart_category_id), the category should be get from the menu ItemId or the category of the product displayed.

in the file
components/com_virtuemart/router.php
the function line 1256
public function getProductId($names,$catId = NULL, $seo_sufix = true ){...}

i have to change the fuction like this ()
if(!isset($prodIds[$hash])){
$prodIds[$hash]['virtuemart_product_id'] = $this->getFieldOfObjectWithLangFallBack('#__virtuemart_products_', 'virtuemart_product_id', 'virtuemart_product_id', 'slug', $productName);
if(empty($categoryName) and empty($catId)){
$prodIds[$hash]['virtuemart_category_id'] = false;
} else if(!empty($categoryName)){
$prodIds[$hash]['virtuemart_category_id'] = $this->getCategoryId($categoryName,$catId ) ;
} else {
//$prodIds[$hash]['virtuemart_category_id'] = false;
                $prodIds[$hash]['virtuemart_category_id'] = $catId;//changed line
}
}



the $catId is passed to the function but false is stored , i don't know why.

$prodIds[$hash]['virtuemart_category_id'] = false;
and not
$prodIds[$hash]['virtuemart_category_id'] = $catId;


The user use the embeded multilanguage for all products/categories .... and falang for menu/module/article....

Stéphane

webmanwebdesign