News:

Support the VirtueMart project and become a member

Main Menu

A suggestion for product type parameters

Started by doorknob, October 01, 2008, 03:07:40 AM

Previous topic - Next topic

doorknob

I have found it necessary to change the data type for the parameter_values column in the product_type_parameter table from varchar(255) to text to accommodate a list of options of greater length. I would expect this to be an issue for a number of users.

In addition, I have also changed classes/product_type_parameter.php so that the columns created for the 'Multiple Value' parameter type are 'text' rather than 'varchar(255)'. I also changed the code so that no index is created for those columns. They are always searched using a function to identify the discrete values from a ; separated list and so an index is of no value.

If you are interested, I changed the code as follows:
Line 211-212
case "V" :
$q .= "varchar(255) " ;

changed to
case "V" :
$q .= "text " ;


and lines 228-239
// Make index for this column
if( $d["parameter_type"] == "T" ) {
$q = "ALTER TABLE `#__{vm}_product_type_" ;
$q .= $d["product_type_id"] . "` ADD FULLTEXT `idx_product_type_" . $d["product_type_id"] . "_" ;
$q .= $db->getEscaped(vmGet($d,'parameter_name')) . "` (`" . $db->getEscaped(vmGet($d,'parameter_name')) . "`);" ;
$db->query($q);
} else {
$q = "ALTER TABLE `#__{vm}_product_type_" ;
$q .= $d["product_type_id"] . "` ADD KEY `idx_product_type_" . $d["product_type_id"] . "_" ;
$q .= $db->getEscaped(vmGet($d,'parameter_name')) . "` (`" . $db->getEscaped(vmGet($d,'parameter_name')) . "`);" ;
$db->query( $q );
}

to
// Make index for this column
if( $d["parameter_type"] == "T" ) {
$q = "ALTER TABLE `#__{vm}_product_type_" ;
$q .= $d["product_type_id"] . "` ADD FULLTEXT `idx_product_type_" . $d["product_type_id"] . "_" ;
$q .= $db->getEscaped(vmGet($d,'parameter_name')) . "` (`" . $db->getEscaped(vmGet($d,'parameter_name')) . "`);" ;
$db->query($q);
} else if( $d["parameter_type"] != "V" ) {
$q = "ALTER TABLE `#__{vm}_product_type_" ;
$q .= $d["product_type_id"] . "` ADD KEY `idx_product_type_" . $d["product_type_id"] . "_" ;
$q .= $db->getEscaped(vmGet($d,'parameter_name')) . "` (`" . $db->getEscaped(vmGet($d,'parameter_name')) . "`);" ;
$db->query( $q );
}


Regards
Phil