Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create product on 3.0.3.1 #7133

Closed
phinq1910 opened this issue Jan 8, 2019 · 18 comments

Comments

Projects
None yet
10 participants
@phinq1910
Copy link

commented Jan 8, 2019

What version of OpenCart are you reporting this for?
Opencart 3.0.3.1

Describe the bug
Cannot create new product. Error following:
Fatal error: Uncaught exception 'Exception' with message 'Error: Duplicate entry '0' for key 'PRIMARY'<br />Error No: 1062<br />INSERT INTO oc_product_advertise_google (product_id, store_id, google_product_category) SELECT p.product_id, p2s.store_id, (SELECT c2gpc.google_product_category FROM oc_product_to_categoryp2c LEFT JOINoc_category_pathcp ON (p2c.category_id = cp.category_id) LEFT JOINoc_category_to_google_product_categoryc2gpc ON (c2gpc.category_id = cp.path_id AND c2gpc.store_id = 0) WHERE p2c.product_id = p.product_id AND c2gpc.google_product_category IS NOT NULL ORDER BY cp.level DESC LIMIT 0,1) asgoogle_product_categoryFROMoc_productp LEFT JOINoc_product_to_storep2s ON (p2s.product_id = p.product_id AND p2s.store_id = 0) LEFT JOINoc_product_advertise_google pag ON (pag.product_id = p.product_id AND pag.store_id=p2s.store_id) WHERE pag.product_id IS NULL AND p2s.store_id IS NOT NULL AND p.product_id IN (51)' in /opencart/3031/system/library/db/mysqli.php:40 St in /opencart/3031/system/library/db/mysqli.php on line 40

To Reproduce
Steps to reproduce the behavior:

  1. Deleted all demo product on back-office
  2. Create a new product
  3. Create a new product again
  4. See error

Server / Test environment (please complete the following information):

  • Local development
  • Operating system: Ubuntu 18.04 LTS
  • PHP version 5.6.38
  • Apache version 2.4.34
  • All browsers

Arthom added a commit to Arthom/opencart that referenced this issue Jan 9, 2019

@hung210

This comment has been minimized.

Copy link

commented Jan 28, 2019

I have the same error when adding a product. How do I fix this error?

@osworx

This comment has been minimized.

Copy link
Contributor

commented Jan 28, 2019

@hung210 if you lokk at this: Arthom@0f4f4b0

@hung210

This comment has been minimized.

Copy link

commented Jan 28, 2019

It's the same version, Version 3.0.3.1. Do I go phpMyAdmin to change the product_advertise table? How do I go about doing what Arthom did?

@osworx

This comment has been minimized.

Copy link
Contributor

commented Jan 28, 2019

simply open phpMyAdmin, go to this table, click in the line oc_product_advertise_google on edit and check the checkbox next to A_I and save

@kg0925

This comment has been minimized.

Copy link

commented Jan 29, 2019

A_I means?? i look in to and found only one check box is unchecked there. screenshot attached. do i need to check that check box on product id row??
screen shot

@osworx

This comment has been minimized.

Copy link
Contributor

commented Jan 29, 2019

A_I = Autoincrement
And not adding a new value, you need to edit the structure.
If you are not able to do that simple task, please ask in the forum or hire an developer.
This here is not a help forum!

@kg0925

This comment has been minimized.

Copy link

commented Jan 31, 2019

i have applied A_I to oc_product_advertise_google and now i am not getting any error. thanks.

@ankit9808

This comment has been minimized.

Copy link

commented Jan 31, 2019

just run the below SQL query and everything will be fine.

ALTER TABLE oc_product_advertise_googleCHANGEproduct_advertise_google_id product_advertise_google_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT;

This query will Modify the oc_product_advertise_google Table and add AUTO_INCREMENT property to this table which solves the issue of duplicate row.

@maskdevil

This comment has been minimized.

Copy link

commented Feb 14, 2019

Simple
Just go to PhphMyAdmin and look for table oc_product_advertise_google and change the Primary Key to Auto Increment, this is a bug of OC version 3.0.3.1 and fix your problem or you can run this script in your console Database

ALTER TABLE oc_product_advertise_google CHANGEproduct_advertise_google_idproduct_advertise_google_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT;
`
Okay?

@hung210

This comment has been minimized.

Copy link

commented Feb 14, 2019

@duinolk

This comment has been minimized.

Copy link

commented Feb 15, 2019

@osworx hi, kindly explain to me how to resolve this issue pls .highly appreciated .
errrrrr

@ankit9808

This comment has been minimized.

Copy link

commented Feb 15, 2019

@osworx hi, kindly explain to me how to resolve this issue pls .highly appreciated .
errrrrr

Install and follow the documentation.
https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=36195&filter_member=Arneacs

@osworx

This comment has been minimized.

Copy link
Contributor

commented Feb 15, 2019

No need to install anything!
The more when it is based on that outdated VQMod - hands off!

Simply do what is described already here several times above.
Either that way: #7133 (comment)
or: #7133 (comment)

And if you do not know how to do such, hire someone.

@Mike-the-one

This comment has been minimized.

Copy link

commented Feb 18, 2019

Thanks, it happened to me too. Since the products were added successfully I already added around 60 products without fixing the db. I have just changed it correct syntax for me is

ALTER TABLE `oc_product_advertise_google`CHANGE`product_advertise_google_idproduct_advertise_google_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT;

Anyhow, the I have 60 products added before I applied this change, this table is empty at this moment. So do I need to manually add something back to this table?

Anything else should I fix since I already have 60 products added?

thanks

@duinolk

This comment has been minimized.

Copy link

commented Feb 20, 2019

i have applied A_I to oc_product_advertise_google and now i am not getting any error. thanks.

hi
//i have applied A_I to oc_product_advertise_google // kindly let me know step by step pls because i'm new for this. thank you

@adamkowalski-pl

This comment has been minimized.

Copy link

commented Mar 10, 2019

Hi guys! I have similar problem but with oc_product_to_store table. I did set the AUTO INCREMENT for product_id in oc_product_to_store table, but still get this error:

Fatal error: Uncaught exception 'Exception' with message 'Error: Duplicate entry '1440' for key 'PRIMARY'
Error No: 1062
INSERT INTO oc_product_to_store SET product_id = '1440', store_id = '0'' in /home/my_website/system/library/db/mysqli.php:40 Stack trace: #0 /home/my_website/system/library/db.php(45): DB\MySQLi->query('INSERT INTO oc_...') #1 /home/my_website/system/storage/modification/admin/model/catalog/product.php(18): DB->query('INSERT INTO oc_...') #2 [internal function]: ModelCatalogProduct->addProduct(Array) #3 /home/my_website/system/storage/modification/system/engine/loader.php(248): call_user_func_array(Array, Array) #4 [internal function]: Loader->{closure}(Array, Array) #5 /home/my_website/system/engine/proxy.php(47): call_user_func_array(Objec in /home/my_website/system/library/db/mysqli.php on line 40 

Products are showing up in shop back- and frontend. I have no ideas left. Please help :/
Opencart 3.0.2.0

@danielkerr

This comment has been minimized.

Copy link
Contributor

commented May 3, 2019

ahh i see it in the 3.3.xxx bbranch.

the fix has been added already

product_advertise_google_id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,

@danielkerr

This comment has been minimized.

Copy link
Contributor

commented May 3, 2019

fixed already.

@danielkerr danielkerr closed this May 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.