Author Topic: Wrong (SEF & noSEF) in product link in Products Module  (Read 4137 times)

osp

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 66
Wrong (SEF & noSEF) in product link in Products Module
« 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

Code: [Select]
//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

Code: [Select]
//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

  • Jr. Member
  • **
  • Posts: 78
Re: Wrong (SEF & noSEF) in product link in Products Module
« Reply #1 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.


osp

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 66
Re: Wrong (SEF & noSEF) in product link in Products Module
« Reply #2 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.

beipink

  • Jr. Member
  • **
  • Posts: 78
Re: Wrong (SEF & noSEF) in product link in Products Module
« Reply #3 on: March 04, 2012, 11:37:47 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

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 66
Re: Wrong (SEF & noSEF) in product link in Products Module
« Reply #4 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.

csimmo

  • Jr. Member
  • **
  • Posts: 50
Re: Wrong (SEF & noSEF) in product link in Products Module
« Reply #5 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?