Forums / Setting Up Categories, Products, Attributes / Autoincrement product_IDs out of sync

Autoincrement product_IDs out of sync

Locked

Views: 1,569

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
21 Jul 2009, 9:11 PM
#1
datagnostics avatar

datagnostics

New Zenner

Join Date:
Jan 2004
Posts:
20
Plugin Contributions:
1

Autoincrement product_IDs out of sync

Trying to add products, I keep getting

Duplicate entry 'BLAH-1' for key 1
in:
[insert into zen_products_description (products_name, products_description, products_url, products_id, language_id)

etc.

Via phpMyAdmin, I see that both my zen_products and zen_products_description tables have autoincrement set on products_id, but they're not at the same number -- the last one in zen_products is 2707, while the last one in zen_products_description is 2712.

I'm guessing that the problem is here, but how do I fix it? Are there any other tables that are likely to be messed up, too?

21 Jul 2009, 9:49 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Autoincrement product_IDs out of sync

  1. The products_description table should NOT have an autoincrement flag set. If it does, then you're probably using an older version and haven't got the update to fix that (which happened in the upgrade to one of the newer versions).

  2. It's not uncommon for there to be additional records in the products_description table vs the products table, because the products_description table has a many-to-one relationship to the products table, with the "many" part being multiple languages used for product names/descriptions.

  3. "Duplicate entry" error messages relate to indexes, not necessarily to auto_increment activity.
    Thus, it might be that whatever record you're attempting to insert is triggering something that creates a duplicate that one of your indexes doesn't allow, on the products_description table.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jul 2009, 1:23 AM
#3
datagnostics avatar

datagnostics

New Zenner

Join Date:
Jan 2004
Posts:
20
Plugin Contributions:
1

Re: Autoincrement product_IDs out of sync

OK, I don't understand what I should look for.

I've removed the autoincrement flag, but this is what I get when I try to add "test product" with description "Test product":

1062 Duplicate entry '2709-1' for key 1
in:
[insert into zen_products_description (products_name, products_description, products_url, products_id, language_id) values ('test product', 'Test product', '', '2709', '1')]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

Where should I look for what, to figure out what the problem is? Thanks for your help.

22 Jul 2009, 2:03 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Autoincrement product_IDs out of sync

Perhaps you can answer the questions asked on the previous screen ...> NOTE: When making a new post, be sure to include relevant information such as:

* What version of Zen Cart are you using?
* Has your site been upgraded? When? From what version(s)?
* What addons have you installed? When?
* In what ways is your site customized or different from a brand new uncustomized install?
* If you're encountering display/layout problems, post your site URL* so it can be seen in action.
* If you're encountering problems that could be related to your server or hosting company, include the name of your hosting company (not their URL).
* HAVE YOU LOOKED IN THE FAQ AREA for answers to your question? (ie: a search for your error message or what you want to edit/change, etc)
* Have you searched the FORUM for your error message or for answers to the question you're asking?
* WHEN did the problem "start"? How does that compare with other events of your hosting company, changes you've made to your site files/addons, or your admin settings, etc?
* If this is your first store, have you tested all aspects of transactions before going live? 

*NOTE: Search engines index this Zen Cart™ support site very quickly. Posting your URL will cause your site and your post to show up in search engines. If you want to prevent that, put spaces between each letter of the domain name in your URL.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jul 2009, 3:00 AM
#5
datagnostics avatar

datagnostics

New Zenner

Join Date:
Jan 2004
Posts:
20
Plugin Contributions:
1

Re: Autoincrement product_IDs out of sync

Zen Cart v1.3.7/v1.3.8
upgraded from 1.3.7 to 1.3.8
addons:
categories_dressing; Column Layout Support
template: gloss_black, but tweaked (different logo, background, button images)

I'm not completely sure when the problem started, because I don't know if the client has been trying to put in products and failing, or not.

22 Jul 2009, 3:14 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Autoincrement product_IDs out of sync

If you look in phpMyAdmin, what indexes do you have on your products_description table? With each index is a list of fields included in that index. Those are important to list here too.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jul 2009, 3:49 AM
#7
datagnostics avatar

datagnostics

New Zenner

Join Date:
Jan 2004
Posts:
20
Plugin Contributions:
1

Re: Autoincrement product_IDs out of sync

I'm not sure I understand you. Here's the Structure of Table: zen_products_description:

Field Type Collation Attributes Null Default
products_id int(11) No None
language_id int(11) No 1
products_name varchar(64) latin1_swedish_ci No
products_description text latin1_swedish_ci Yes NULL
products_url varchar(255) latin1_swedish_ci Yes NULL
products_viewed int(5) Yes 0

I've now dropped the autoincrement, as you see.

22 Jul 2009, 3:52 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Autoincrement product_IDs out of sync

Okay, that's the table structure. What are the indexes on the table?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jul 2009, 1:27 PM
#9
datagnostics avatar

datagnostics

New Zenner

Join Date:
Jan 2004
Posts:
20
Plugin Contributions:
1

Re: Autoincrement product_IDs out of sync

Keyname  	      Type  	Cardinality   	Field
PRIMARY 	        PRIMARY 	223  	products_id, language_id
idx_products_name_zen 	INDEX 	None  		products_name

In case this isn't clear, both products_id and language_id are listed as fields under PRIMARY.

22 Jul 2009, 4:48 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Autoincrement product_IDs out of sync

Okay, so those are correct.

The error message is thus coming as a result of already having a products_description record for a product_id numbered 2709 for language 1.

You'll have to clean up the records so that you don't have any product_id records in products_description that don't match the records in your products table.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jul 2009, 7:06 PM
#11
datagnostics avatar

datagnostics

New Zenner

Join Date:
Jan 2004
Posts:
20
Plugin Contributions:
1

Re: Autoincrement product_IDs out of sync

Thank you! That works.