cancel
Showing results for 
Search instead for 
Did you mean: 

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row

Hey guys, I want add product as usual but recently I can't add configurable and simple product, and the website shown the below code. I tried to duplicate the existing product and edit it but still can't work. Please help me to fix it.

Many Thanks!

 

The code: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`verbatim_sg`.`catalog_product_entity`, CONSTRAINT `FK_CAT_PRD_ENTT_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID` FOREIGN KEY (`attribute_set_id`) REFERENCES `eav_attribute_set` (`attribute_set_id`) O), query was: INSERT INTO `catalog_product_entity` (`entity_type_id`, `type_id`, `created_at`, `updated_at`) VALUES (?, ?, '2019-06-25 01:44:58', '2019-06-25 01:44:58')

2 REPLIES 2

Re: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row

HI @mei suet_wong 

Which magento version you are using?

How you imported products last time? May be there are some issue with last imported product. Please check once attribute_set_id for id. 


Or check your code if you are using any custom module to create or override a file where you are assigning 

setAttributeSetId 


Try re-indexing once and try. 

Re: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row

Hello @mei suet_wong 

 

Are you using any module related to customize the product or attribute set change module?

 

If yes then check disable that module and check it.

 

 

Also, this error happens when somebody removed your attribute set. confirm that attribute set exists or not.

 

 

If works then mark as a solution.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer