VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: osp on March 03, 2012, 20:39:10 PM

Title: Wrong (SEF & noSEF) in product link in Products Module
Post by: osp on March 03, 2012, 20:39:10 PM
VM202 (SVN), Apache, MySQL5, PHP5.3

Products module (featured, TOP) uses $product->link as anchor.
The problem addressed here is that this link contains category from request, not from product itself.
Thus clicking this link leads to bad Breadcrums and Category module synchro.

It seems someone (Max, Patrick?) had a problem with this code already...

models/product.php 570


//There is someone who can explain me this?
//Note by Patrick  Used for ordering product in category
$product->virtuemart_category_id = JRequest::getInt('virtuemart_category_id', 0);


and FIX is


//OSP correction / get category of the product from the product itself?
//Is this fix okay
if ( is_array($product->categories) && !empty($product->categories) )
$product->virtuemart_category_id = $product->categories[0]->virtuemart_category_id;


Is this FIX okay or there are some hidden side effect in product model depending on this behaviour (where IMO teher's no logic describing such a behaviour)

Title: Re: Wrong (SEF & noSEF) in product link in Products Module
Post by: beipink on March 04, 2012, 02:19:53 AM
Hi Ondrejspilka,
Are you dealing with the same issue reported here http://forum.virtuemart.net/index.php?topic=98584.0??

I wouldn't think the below patch is related to that, at least not to the problem of bad breadcrumbs/URL with SEO enabled as reported on the above link.

Title: Re: Wrong (SEF & noSEF) in product link in Products Module
Post by: osp on March 04, 2012, 09:04:04 AM
Yes it seems thi sis the same issue.

Needed condition is that request contains any category id (even empty). Then bad category can be applied to product links in product modules.
Title: Re: Wrong (SEF & noSEF) in product link in Products Module
Post by: beipink on March 04, 2012, 11:37:47 AM
Quote from: ondrejspilka on March 04, 2012, 09:04:04 AM
Yes it seems thi sis the same issue.

Needed condition is that request contains any category id (even empty). Then bad category can be applied to product links in product modules.

Is this a fix? would you pls elaborate as I don't understand what do you mean.

Title: Re: Wrong (SEF & noSEF) in product link in Products Module
Post by: osp on March 04, 2012, 12:17:54 PM
IMO this is the fix but must be validated sicne it can affect wide range of situations.
Title: Re: Wrong (SEF & noSEF) in product link in Products Module
Post by: csimmo on November 20, 2012, 05:07:27 AM
I am getting this issue with VM 2.0.14. I would get both my test products listing in a category that they shouldn't be in with SEF enabled, however it seems the fix is no longer valid. Line 570 seems to be different. Does someone know the new fix for this?