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: Fable on July 07, 2008, 15:46:54 PM

Title: Solution to bug regarding SQL error when duplicating product with child products
Post by: Fable on July 07, 2008, 15:46:54 PM
I found a bug in classes/ps_product.php

Line 412 through 414 contains a mysql query for copying product attributes.

Faulty code:

$q = "INSERT INTO #__{vm}_product_attribute
                  SELECT '$new_product_id', attribute_name, attribute_value
                  FROM #__{vm}_product_attribute WHERE product_id='$child_id'";
$db->query( $q );


Correct code:

$q = "INSERT INTO #__{vm}_product_attribute
                  SELECT NULL,'$new_product_id', attribute_name, attribute_value
                  FROM #__{vm}_product_attribute WHERE product_id='$child_id'";
$db->query( $q );

(The change is SELECT NULL,......)

Or you could specify which attributes to add. You got a illegal column count with the original code since it doesn't specify the attribute_id column (which is auto_incrementing)
Title: Re: Solution to bug regarding SQL error when duplicating product with child products
Post by: Soeren on July 07, 2008, 19:40:04 PM
Thank you,
will be fixed in VM 1.1.2.

ciao, Sören
Title: Re: Solution to bug regarding SQL error when duplicating product with child products
Post by: Fable on August 08, 2008, 12:41:15 PM
I didn't see this in the changelog? Any news?
Title: Re: Solution to bug regarding SQL error when duplicating product with child products
Post by: aravot on August 08, 2008, 22:06:07 PM
Sorry must have forgot to add it to the changelog, but correction has been made to the file.