VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: CZDave on July 14, 2014, 14:21:55 PM

Title: virtuemart_category_id contains text instead of numerical ID
Post by: CZDave on July 14, 2014, 14:21:55 PM
Hi,

I am a developer of ARTIO JoomSEF and we've just noticed the following problem in VirtueMart 2.6.6 causing the virtuemart_category_id property being filled with some text instead of category numerical ID under some conditions. In the file /administrator/components/com_virtuemart/models/product.php in function getProductSingle() around line number 1074 there is the following code:
if (!empty($product->categories) and is_array ($product->categories) and array_key_exists (0, $product->categories)) {
    $product->virtuemart_category_id = $product->canonCatLink;
    //vmdebug('I take for product the main category ',$product->virtuemart_category_id,$product->categories);
}


Which (when certain conditions are met) causes the virtuemart_category_id to be set to some text obtained from the $product->product_url because of the following code around line 1042:
if(!empty($product->product_url)){
    $product->canonCatLink = $product->product_url;
}


We've fixed the problem for us by changing line 1074 from:
$product->virtuemart_category_id = $product->canonCatLink;
to:
$product->virtuemart_category_id = $product->categories[0];

Hope this helps.

Best regards,
ARTIO JoomSEF developer
Title: Re: virtuemart_category_id contains text instead of numerical ID
Post by: Milbo on July 15, 2014, 09:09:55 AM
Thank you, if you check the if line before

if (!empty($product->categories) and is_array ($product->categories) and array_key_exists (0, $product->categories)) {

It was clearly meant that way.

Did you also test already vm3? There I cleaned that