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 new product M2.1 sql error #6101

Closed
adamaoo opened this issue Aug 10, 2016 · 7 comments
Closed

Cannot create new product M2.1 sql error #6101

adamaoo opened this issue Aug 10, 2016 · 7 comments

Comments

@adamaoo
Copy link

adamaoo commented Aug 10, 2016

Preconditions

  1. Apache/2.4.18 (Win64) PHP/7.0.9
    5.7.11 - MySQL

Steps to reproduce

  1. Create new product in Magento 2.1

Expected result

  1. New product should be created

Actual result

  1. Product is not created, following error appears:

Cannot add or update a child row: a foreign key constraint fails (magento2.catalog_product_entity, CONSTRAINT CATALOG_PRODUCT_ENTITY_ENTITY_ID_SEQUENCE_PRODUCT_SEQUENCE_VALUE FOREIGN KEY (entity_id) REFERENCES sequence_product (sequence_value) )

@erlisdhima
Copy link

This could be related to MySQL version. Currently magento 2.1 supports 5.6: http://devdocs.magento.com/guides/v2.1/install-gde/system-requirements-tech.html

Here you can see a notice that it does not support 5.7:
http://devdocs.magento.com/guides/v2.1/install-gde/prereq/mysql.html#instgde-prereq-mysql57-ub16

@allanpaiste
Copy link

allanpaiste commented Aug 10, 2016

I guess you're reporting this for Magento EE (sequence_product being table only relevant and available on EE).

What type of a product were you trying to create? Could you provide more specific steps because i could create simple product in 2.1 EE without any problems.

Here's what I did:

  1. Installed Magento 2.1 EE
  2. logged into admin
  3. Navigated to PRODUCTS >> Inventory >> Catalog
  4. Clicked [Add Product](this will mean that a simple product will be created by default)
  5. Filled in: Product name (used: asdasd), sku (was autofilled based on name, changed it to: asd1), price (100)
  6. Saved the product

EXPECTED: Product created
ACTUAL Product created

System: Ubuntu 16.04 VB image / Apache 2.4.18 / Mysql 5.6.31-77.0 / PHP7.0.8-4

What kind of product should be created? More detailed steps would help (starting from "Install fresh copy of Magento 2.1 CE/EE) as it would make it easier to figure out what's happening and catch the error :)

I have a feeling that it might be that there's a item in the sequence_product that is not matched with a catalog_product_entity row. Was something done with the DB disabled constraints? Could you check that rows in catalog_product_entity and sequence_product match up?

@adamaoo
Copy link
Author

adamaoo commented Aug 11, 2016

@allanpaiste I was creating simple product, same problem appears for creating category.
Additionally, when installing M2.1 by URL /setup/#/install, i have to set in mysql:
SET foreign_key_checks = 0;
otherwise install stops at:
Installing data...
[ERROR] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento2.cms_page, CONSTRAINT CMS_PAGE_PAGE_ID_SEQUENCE_CMS_PAGE_SEQUENCE_VALUE FOREIGN KEY (page_id) REFERENCES sequence_cms_page (sequence_value) ON DELETE CASCADE)

I changed mysql to 5.6.32 same problem appears on install, so probably on creating product/category also.
Now my setup is: Windows 10, WAMP = mysql 5.6.32, php 7.0.9

@adamaoo
Copy link
Author

adamaoo commented Aug 11, 2016

Same problem appears for me when i want to add new row directly in sql / phpmyadmin.

#1452 - Cannot add or update a child row: a foreign key constraint fails (magento2.catalog_product_entity, CONSTRAINT CATALOG_PRODUCT_ENTITY_ENTITY_ID_SEQUENCE_PRODUCT_SEQUENCE_VALUE FOREIGN KEY (entity_id) REFERENCES sequence_product (sequence_value) )

@veloraven veloraven self-assigned this Aug 15, 2016
@veloraven
Copy link
Contributor

@adamaoo thank you for your report.
Please provide information if it was clear Magento install or upgrade from some other version.
Please let us know if you can reproduce this issue on Linux operating system as Magento does not support Windows.
Also if your question refers to EE please address it to Support.

@veloraven
Copy link
Contributor

According to contributor guide, tickets without response for two weeks should be closed.
If this issue still reproducible please feel free to create the new one: format new issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result and specify Magento version.

@sylvainraye
Copy link
Contributor

For future readers. it's not an issue. It's related how works Magento EE. You need to get the entity_id from the sequence_product table. The id is based on the next auto increment value from this sequence_product table. You need to insert a new value and reuse it while inserting a new product into the catalog_product_entity table. See the class \Magento\CatalogStaging\Model\ResourceModel\ProductSequence

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

No branches or pull requests

5 participants