Wrong (SEF & noSEF) in product link in Products Module

Started by osp, March 03, 2012, 20:39:10 PM

Previous topic - Next topic

osp

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)


beipink

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.


osp

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.

beipink

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.


osp

IMO this is the fix but must be validated sicne it can affect wide range of situations.

csimmo

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?