Copy Product Problem
#1
Posted 10 August 2012 - 08:41 AM
Everything works perfectly until I try to copy an item (or, I suspect, move it as well). The copy script selects the data from all 9 columns of Table Products Description but then combines the extra 3 TEXT columns to the original products_description and then tries to insert the result back into Table Products Description.
Consequently I'm getting a 1136 - Column count doesn't match value count at row 1
Does anyone have any idea where my problem may lie or where the copy script gets it's select information from?
Working with osCommerce 2.3.1
Add-Ons so far Installed:
Add date and order number to invoice and packing slip,
Products Cycle Slideshow,
Detailed Monthly Sales,
Holiday Settings,
Tracking Module for 2.3
#2
Posted 10 August 2012 - 08:44 AM
You need to make sure that the query pick the 3 new fields and then insert them again
$description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
while ($description = tep_db_fetch_array($description_query)) {
tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
}
#3
Posted 10 August 2012 - 08:57 AM
Thanks for the fast response - the answer is no because I don't seem to have that in my categories.php - I have the 2010 version of 2.3.1 running at the moment
Is that in the 2.3.3 categories.php?
Working with osCommerce 2.3.1
Add-Ons so far Installed:
Add date and order number to invoice and packing slip,
Products Cycle Slideshow,
Detailed Monthly Sales,
Holiday Settings,
Tracking Module for 2.3
#4
Posted 10 August 2012 - 08:59 AM
#5
Posted 10 August 2012 - 01:36 PM
I have indeed updated both the (copy_to_confirm) search query and the insert query, and both those bits seem to be working alright - the script searches and get the data from all nine columns, it tries to put that resulting data back into the table...
but in between times it has somehow joined all the data from my new columns to the products_description so the script is now trying to fit 6 fields into 9 columns
Working with osCommerce 2.3.1
Add-Ons so far Installed:
Add date and order number to invoice and packing slip,
Products Cycle Slideshow,
Detailed Monthly Sales,
Holiday Settings,
Tracking Module for 2.3
#6
Posted 10 August 2012 - 01:52 PM
<EDIT>
'copy_to' as a link seems to work as well - which narrows it down to 'copy_to' duplicate
and 'delete' works as well
Edited by Xpajun, 10 August 2012 - 01:59 PM.
Working with osCommerce 2.3.1
Add-Ons so far Installed:
Add date and order number to invoice and packing slip,
Products Cycle Slideshow,
Detailed Monthly Sales,
Holiday Settings,
Tracking Module for 2.3
#7
Posted 10 August 2012 - 04:19 PM
Xpajun, on 10 August 2012 - 01:52 PM, said:
Just below
} elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {
you will find
$description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
while ($description = tep_db_fetch_array($description_query)) {
tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
}
If you are using multiple languages you will need to edit admin/languages.php.Edit this section
// create additional products_description records
$products_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, pd.products_url from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where pd.language_id = '" . (int)$languages_id . "'");
while ($products = tep_db_fetch_array($products_query)) {
tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url) values ('" . (int)$products['products_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($products['products_name']) . "', '" . tep_db_input($products['products_description']) . "', '" . tep_db_input($products['products_url']) . "')");
}
and this section
tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where language_id = '" . (int)$lID . "'");
I have a problem for your solution
I reject your reality and substitute my own
My mind not only wanders, it sometimes leaves completely
The problem with the gene pool is that there is no lifeguard
Everyone’s entitled to my opinion
Links
Security
SSL Help
Basics for design
Basics for design V2.3+
How Do I ...?
#8
Posted 10 August 2012 - 06:15 PM
bktrain, on 10 August 2012 - 04:19 PM, said:
Just below
} elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {
you will find
$description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
while ($description = tep_db_fetch_array($description_query)) {
tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
}
That's the same bit of code that George mentions above and which I have altered with my extra field/column names - the thing is that that bit seems to work - it gets the data from all 9 of my table columns and then tries to insert them back into all 9 columns but in between times (sometime during the copy process?) it joins my new field/column data to the products_description data (and reduces the value count back to 6)
bktrain, on 10 August 2012 - 04:19 PM, said:
Edit this section
// create additional products_description records
$products_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, pd.products_url from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where pd.language_id = '" . (int)$languages_id . "'");
while ($products = tep_db_fetch_array($products_query)) {
tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url) values ('" . (int)$products['products_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($products['products_name']) . "', '" . tep_db_input($products['products_description']) . "', '" . tep_db_input($products['products_url']) . "')");
}
and this section
tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where language_id = '" . (int)$lID . "'");
I hadn't found that languages one - I've updated it now - but it's not made a difference (only have the one language)
Working with osCommerce 2.3.1
Add-Ons so far Installed:
Add date and order number to invoice and packing slip,
Products Cycle Slideshow,
Detailed Monthly Sales,
Holiday Settings,
Tracking Module for 2.3
#9
Posted 10 August 2012 - 06:32 PM
instead of
. tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_
I'd written
. tep_db_input($description['products_description']) . tep_db_input($description['products_
Thanks George and Brian for helping to look in the right places to get it sorted
Working with osCommerce 2.3.1
Add-Ons so far Installed:
Add date and order number to invoice and packing slip,
Products Cycle Slideshow,
Detailed Monthly Sales,
Holiday Settings,
Tracking Module for 2.3
#10
Posted 10 August 2012 - 07:38 PM
Xpajun, on 10 August 2012 - 06:15 PM, said:
Quote
Glad you got it working
Edited by bktrain, 10 August 2012 - 07:39 PM.
I have a problem for your solution
I reject your reality and substitute my own
My mind not only wanders, it sometimes leaves completely
The problem with the gene pool is that there is no lifeguard
Everyone’s entitled to my opinion
Links
Security
SSL Help
Basics for design
Basics for design V2.3+
How Do I ...?
#11
Posted 11 August 2012 - 04:01 AM
. tep_db_input($description['products_description']) . tep_db_input($description['products_
What to do, things like this happen
Just for general info and about your above statement
Xpajun, on 10 August 2012 - 01:52 PM, said:
...
'copy_to' as a link seems to work as well - which narrows it down to 'copy_to' duplicate
1) The copy product action has to ways of working
Copy as link, just add one more entry to table "products to categories", the product tables themselves remain untuched
Copy as duplicate, is the real copy action, it "read" all data for an existing product and insert it again with a new product id
2) The move product action, is similar to the copy as link: All it does is, to change the entry in table products to categories, the product tables are not affected
Edited by multimixer, 11 August 2012 - 04:02 AM.









