VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Quality & Testing VirtueMart 1.1.x => Virtuemart 1.1 Development (Archiv) => Q&T Resolved => Topic started by: doorknob on August 13, 2008, 02:58:08 am

Title: Bug in Product Type Parameter processing (and quick fix)
Post by: doorknob on August 13, 2008, 02:58:08 am
The search by product type parameter facility uses the mysql function FIND_IN_SET() when searching 'multiple value' parameters. This function requires that the items in the set be separated by commas. The values in the product type parameter fields are separated by ';' and so the function fails. The routines that maintain parameter values must be changed to use commas as the separator when saving and retrieving values from 'multiple value' types. It would also make sense to also change the separator in the 'Possible Values' field to a comma to eliminate any errors that might be caused by having a comma embedded in a value.

Regards
Phil

As a short term solution (with potential performance penalty compared with a solution involving switching from semi-colon to comma separators) I have implemented the following changed to shop_browse_queries.php:

Line 227 changed from
Code: [Select]
$comp = "FIND_IN_SET('$get_item_value',`$parameter_name`)";
to
Code: [Select]
$comp = "FIND_IN_SET('$get_item_value',REPLACE(`$parameter_name`,';',','))";
and line 235 from
Code: [Select]
array_push($comp,"FIND_IN_SET('$value',`$parameter_name`)");
to
Code: [Select]
array_push($comp,"FIND_IN_SET('$value',REPLACE(`$parameter_name`,';',','))");

Regards
Phil
Title: Re: Bug in Product Type Parameter processing (and quick fix)
Post by: Szolo on February 14, 2009, 13:11:19 pm
Thank you very much!!!

I was in trouble with this...
Title: Re: Bug in Product Type Parameter processing (and quick fix)
Post by: aravot on February 26, 2009, 00:23:00 am
Fixed in 1.1.4
Title: Re: Bug in Product Type Parameter processing (and quick fix)
Post by: mylonojr on March 11, 2009, 09:07:12 am
The search by product type parameter facility uses the mysql function FIND_IN_SET() when searching 'multiple value' parameters. This function requires that the items in the set be separated by commas. The values in the product type parameter fields are separated by ';' and so the function fails. The routines that maintain parameter values must be changed to use commas as the separator when saving and retrieving values from 'multiple value' types. It would also make sense to also change the separator in the 'Possible Values' field to a comma to eliminate any errors that might be caused by having a comma embedded in a value.

Regards
Phil

As a short term solution (with potential performance penalty compared with a solution involving switching from semi-colon to comma separators) I have implemented the following changed to shop_browse_queries.php:

Line 227 changed from
Code: [Select]
$comp = "FIND_IN_SET('$get_item_value',`$parameter_name`)";
to
Code: [Select]
$comp = "FIND_IN_SET('$get_item_value',REPLACE(`$parameter_name`,';',','))";
and line 235 from
Code: [Select]
array_push($comp,"FIND_IN_SET('$value',`$parameter_name`)");
to
Code: [Select]
array_push($comp,"FIND_IN_SET('$value',REPLACE(`$parameter_name`,';',','))");

Regards
Phil

I am using v1.1.3 and the above mentioned lines are 455 and 471 acordingly.
Is it O.K. if I change them, cause I am facing the same problem?
Title: Re: Bug in Product Type Parameter processing (and quick fix)
Post by: doorknob on March 11, 2009, 11:25:05 am
As Avarot said in the previous post, this will not be fixed until 1.1.4. so go aheda and make the change. The line numbers will have changed because I made the original post about 6 months ago but so long as you find the lines that match the code shown then it should fix the problem.
Phil
Title: Re: Bug in Product Type Parameter processing (and quick fix)
Post by: preciouscreations on February 04, 2011, 02:21:41 am
The code is present in the shop_browse_quaries.php (VM 1.1.6) but the problem still exists I still get att1;att2 and so on when selecting multiple values.
Title: Re: Bug in Product Type Parameter processing (and quick fix)
Post by: doorknob on February 07, 2011, 02:09:56 am
Quote
but the problem still exists I still get att1;att2 and so on when selecting multiple values.
Can you provide a proper description of the problem you are having?
Title: Re: Bug in Product Type Parameter processing (and quick fix)
Post by: useris on June 13, 2011, 23:54:14 pm
Hi,

I've just started to use this plugin. But when I make search for type which is "eq" = it find to many products, even if product type is not equal. Is it configuration problem? (I am not selecting parameter from dropdown box I just type parameter in the search box)

And one more issue for me is that some of my product type ends with zero but so I must set up product parameter as Text. If I set it as Float Mysql will delete the zero in the end of the parameter. How to make it Float but keep zero?
Title: Re: Bug in Product Type Parameter processing (and quick fix)
Post by: doorknob on June 19, 2011, 01:32:19 am
Quote
(I am not selecting parameter from dropdown box I just type parameter in the search box)
I'm not at all clear on how you are trying to do a search. A fuller explanation of how you are trying to do the search would be helpful.
Quote
And one more issue for me is that some of my product type ends with zero but so I must set up product parameter as Text. If I set it as Float Mysql will delete the zero in the end of the parameter. How to make it Float but keep zero?
Again, I'm not clear on what you mean. zeros on the 'end' of a string (i.e. trailing) should not get lost. If you mean leading zeros and they are significant then you must capture the value as a text string and not a float. You don't say why it needs to be a float. If a value is stored as a float but you want the presentation to include leading zeros, you can edit your vm template files to format the value any way you like
Title: Re: Bug in Product Type Parameter processing (and quick fix)
Post by: useris on June 19, 2011, 09:13:51 am
Thanks for your reply but problem was solved.

Quote
(I am not selecting parameter from dropdown box I just type parameter in the search box)
I'm not at all clear on how you are trying to do a search. A fuller explanation of how you are trying to do the search would be helpful.
Quote
And one more issue for me is that some of my product type ends with zero but so I must set up product parameter as Text. If I set it as Float Mysql will delete the zero in the end of the parameter. How to make it Float but keep zero?
Again, I'm not clear on what you mean. zeros on the 'end' of a string (i.e. trailing) should not get lost. If you mean leading zeros and they are significant then you must capture the value as a text string and not a float. You don't say why it needs to be a float. If a value is stored as a float but you want the presentation to include leading zeros, you can edit your vm template files to format the value any way you like