4

I found there is issue with row_id and entity_id in this catalog_product_entity. I'm not able to assign product to category, it gives this error:

Something went wrong while saving the category.SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (mydb.catalog_category_product, CONSTRAINT CAT_CTGR_PRD_PRD_ID_SEQUENCE_PRD_SEQUENCE_VAL FOREIGN KEY (product_id) REFERENCES sequence_product (sequence_value) ON DELETE CA), query was: INSERT INTO catalog_category_product (category_id,product_id,position) VALUES (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?)

Table values in database is:

enter image description here

2
  • Can you please let me know how you have resolved this issue Commented Apr 29, 2019 at 8:40
  • i have empty all tables of products and categories. Commented Apr 30, 2019 at 4:59

2 Answers 2

0

We have faced the similar issue on Magento commerce after upgrading to 2.1.6 to 2.1.17. After investigating further, I found Magento_VisualMerchandiser creating the issue. When I disabled it, no sql error is displaying when assigning product to a categories.

Although this is not the solution, But it will be help full.

Ref- https://github.com/magento/magento2/issues/16227

3
  • yes, there is some issue with save position: Magento\VisualMerchandiser\Block\Adminhtml\Category\Merchandiser\Tile Commented Apr 30, 2019 at 9:21
  • after comment of save position script, assign product to category functionality is working good Commented Apr 30, 2019 at 9:23
  • There are many dependencies for this extension. 10 other modules require it, so we can't just disable it.
    – Black
    Commented Oct 4, 2022 at 10:00
0

I had the same issue. The problem is, that the sequence_value does not exist in the table sequence_product and therefor the error is thrown.

Just add the product id into that table in the correct place at its order position! Don't just put it at the bottom, this will mess everything up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.