I am updating products programmatically and then adding images to them via
$product->addImageToMediaGallery($file, array( < flags > ), true, false);
For some products, this works just fine, for others it gives me
SQLSTATE: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`db11057204-walthermagestaging`.`catalog_product_entity_media_gallery_value`, CONSTRAINT `FK_CAT_PRD_ENTT_MDA_GLR_VAL_VAL_ID_CAT_PRD_ENTT_MDA_GLR_VAL_ID` FOREIGN KEY (`value_id`) REFERENCES `c), query was: INSERT INTO `catalog_product_entity_media_gallery_value` (`value_id`, `store_id`, `label`, `position`, `disabled`) VALUES (?, ?, ?, ?, ?)
I have not been able to determine a pattern yet.
It says that a foreign key constraint fails, but in the error message, the target of the FK is cut off after the first letter, which leaves me clueless. Where to look? What to do?
Since these products are created automatically, could it be that there is no
media_gallery eav attribute? If so, how can I check?