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 · 22 comments
Closed

Cannot create product on 3.0.3.1 #7133

phinq1910 opened this issue Jan 8, 2019 · 22 comments

Comments

@phinq1910
Copy link

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
@hung210
Copy link

hung210 commented Jan 28, 2019

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

@osworx
Copy link
Contributor

osworx commented Jan 28, 2019

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

@hung210
Copy link

hung210 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
Copy link
Contributor

osworx 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
Copy link

kg0925 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
Copy link
Contributor

osworx 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
Copy link

kg0925 commented Jan 31, 2019

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

@ghost
Copy link

ghost 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
Copy link

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
Copy link

hung210 commented Feb 14, 2019 via email

@duinolk
Copy link

duinolk commented Feb 15, 2019

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

@ghost
Copy link

ghost 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
Copy link
Contributor

osworx 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
Copy link

Mike-the-one 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
Copy link

duinolk 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
Copy link

adamkowalski-pl 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
Copy link
Member

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
Copy link
Member

fixed already.

@arjunaken
Copy link

A Database Error Occurred

Error Number: 1062

Duplicate entry '10' for key 'PRIMARY'

INSERT INTO berkas_lamaran_kerja (n omor, nama_depan, nama_belakang, email, no_telepon, tempat_lahir, tgl_lahir, no_ktp, kendaraan, job, foto_ktp, foto_stnk, foto_sim, foto_diri, is_valid) VALUES (10, 'Agus', 'Junaken', 'veronika4905@gmail.com', '081237302013', 'sragen', '1981-02-20', 'arjuna ken', '19', '1', '', '', '', '', 'no')

Filename: models/M_upload.php

Line Number: 13

@arjunaken
Copy link

please can help me what wrong in my database..??thanks

@kamleshwebtech
Copy link

Answer: Run below solution to fix it

Fixed the problem. Logged in to phpMyAdmin.
Remove: oc_product_advertise_google.

Go to -> SQL
Copy and paste the next lines:

DROP TABLE IF EXISTS oc_product_advertise_google;
CREATE TABLE oc_product_advertise_google (
product_advertise_google_id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
product_id int(11) DEFAULT NULL,
store_id int(11) NOT NULL DEFAULT '0',
has_issues tinyint(1) DEFAULT NULL,
destination_status enum('pending','approved','disapproved') NOT NULL DEFAULT 'pending',
impressions int(11) NOT NULL DEFAULT '0',
clicks int(11) NOT NULL DEFAULT '0',
conversions int(11) NOT NULL DEFAULT '0',
cost decimal(15,4) NOT NULL DEFAULT '0.0000',
conversion_value decimal(15,4) NOT NULL DEFAULT '0.0000',
google_product_category varchar(10) DEFAULT NULL,
condition enum('new','refurbished','used') DEFAULT NULL,
adult tinyint(1) DEFAULT NULL,
multipack int(11) DEFAULT NULL,
is_bundle tinyint(1) DEFAULT NULL,
age_group enum('newborn','infant','toddler','kids','adult') DEFAULT NULL,
color int(11) DEFAULT NULL,
gender enum('male','female','unisex') DEFAULT NULL,
size_type enum('regular','petite','plus','big and tall','maternity') DEFAULT NULL,
size_system enum('AU','BR','CN','DE','EU','FR','IT','JP','MEX','UK','US') DEFAULT NULL,
size int(11) DEFAULT NULL,
is_modified tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (product_advertise_google_id),
UNIQUE KEY product_id_store_id (product_id,store_id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

@ocdevcn
Copy link

ocdevcn commented May 28, 2023

I use this to solve the problem.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests