Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Copy Product Problem


Xpajun

Recommended Posts

I've recently added to Table Products Description 3 extra columns with a corresponding 3 extra fields in categories.php to add data in them. All 3 extra columns are TEXT and add additional details to the item description such as technical specifications etc.

 

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?

My store is currently running Phoenix 1.0.3.0

I'm currently working on 1.0.7.2 and hope to get it live before 1.0.8.0 arrives (maybe 🙄 )

I used to have a list of add-ons here but I've found that with the ones that supporters of Phoenix get any other add-ons are not really neccessary

Link to comment
Share on other sites

Did you update the "action" "copy_to_confirm" in file admin/categories.php?

 

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')");
	    }

Link to comment
Share on other sites

Hi George,

 

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?

My store is currently running Phoenix 1.0.3.0

I'm currently working on 1.0.7.2 and hope to get it live before 1.0.8.0 arrives (maybe 🙄 )

I used to have a list of add-ons here but I've found that with the ones that supporters of Phoenix get any other add-ons are not really neccessary

Link to comment
Share on other sites

Sorry for the delay in answering, George, yes - I do have that - obviously in too much of a hurry earlier...

 

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

My store is currently running Phoenix 1.0.3.0

I'm currently working on 1.0.7.2 and hope to get it live before 1.0.8.0 arrives (maybe 🙄 )

I used to have a list of add-ons here but I've found that with the ones that supporters of Phoenix get any other add-ons are not really neccessary

Link to comment
Share on other sites

Just done a check now - it shows that 'move_to' works but not 'copy_to'

 

 

<EDIT>

 

'copy_to' as a link seems to work as well - which narrows it down to 'copy_to' duplicate

 

and 'delete' works as well

My store is currently running Phoenix 1.0.3.0

I'm currently working on 1.0.7.2 and hope to get it live before 1.0.8.0 arrives (maybe 🙄 )

I used to have a list of add-ons here but I've found that with the ones that supporters of Phoenix get any other add-ons are not really neccessary

Link to comment
Share on other sites

narrows it down to 'copy_to' duplicate

That is in the copy_to_confirm case as well.

 

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 . "'");

Link to comment
Share on other sites

Hi Brian - thanks for your input,

 

That is in the copy_to_confirm case as well.

 

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)

 

 

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 hadn't found that languages one - I've updated it now - but it's not made a difference (only have the one language)

My store is currently running Phoenix 1.0.3.0

I'm currently working on 1.0.7.2 and hope to get it live before 1.0.8.0 arrives (maybe 🙄 )

I used to have a list of add-ons here but I've found that with the ones that supporters of Phoenix get any other add-ons are not really neccessary

Link to comment
Share on other sites

Problem solved - my bad coding :blush:

 

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

My store is currently running Phoenix 1.0.3.0

I'm currently working on 1.0.7.2 and hope to get it live before 1.0.8.0 arrives (maybe 🙄 )

I used to have a list of add-ons here but I've found that with the ones that supporters of Phoenix get any other add-ons are not really neccessary

Link to comment
Share on other sites

That's the same bit of code that George mentions above

So much for me paying attention

 

Problem solved - my bad coding :blush:

I was just coming back to say I just tried with no problems.

 

Glad you got it working

Link to comment
Share on other sites

Julian, yes, this was not very nice

. 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

Just done a check now - it shows that 'move_to' works but not 'copy_to'

...

'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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...