For some reason we had a problem with magento 2.4.6 databaase and we forced to restart database without checking that indexers were working.
Now when I duplicate a product from admin I get this error:
main.CRITICAL: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`new_magento`.`catalog_product_entity_int`, CONSTRAINT `CAT_PRD_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID` FOREIGN KEY (`attribute_id`) REFERENCES `eav_attribute` (`attribute_id`) ON DELETE CASCADE)
and in exception.log
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`new_magento`.`catalog_product_entity_int`, CONSTRAINT `CAT_PRD_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID` FOREIGN KEY (`attribute_id`) REFERENCES `eav_attribute` (`attribute_id`) ON DELETE CASCADE), query was: INSERT INTO `catalog_product_entity_int` (`attribute_id`,`store_id`,`value`,`row_id`) VALUES (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?)
I am trying to decode this.
For my parent table eav_attribute
primary key is attribute_id
My child table has a foreign key also attribute_id
and it is identified as CAT_PRD_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID
which if I understand right it is catalog_product_entity_int
table.
But I cannot understand ATTR_ID_EAV_ATTR_ATTR_ID
section
What I understand is that in catalog_product_entity_int
an attribute_id
fails with no mathing value.
I am confused.
Can someone help me to identify which is and solve this please?