0

Good morning. I have a CRON stuck because it fails to run due to this error. How can I avoid it and where should I intervene?

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (H****_mag2new.catalog_product_entity_media_gallery_value_video, CONSTRAINT FK_6FDF205946906B0E653E60AA769899F8 FOREIGN KEY (value_id) REFERENCES catalog_product_entity_media_gallery ), query was: DELETE FROM catalog_product_entity_media_gallery WHERE (value_id = '1913671126' )

2
  • what cron is this? it looks like you are cleaning up some media elements, buy the video is not deleted before deleting the media galery entry Commented Jun 13, 2024 at 12:01
  • Please also translate your title to English, per Stack Exchange requirements. Commented Jun 13, 2024 at 13:25

2 Answers 2

0

As your error message that there are dependent records in the catalog_product_entity_media_gallery_value_video table that reference the value_id you're trying to delete.

solution depend on what you trying achieve with your cron action if you want to delete the record. first you need to delete the dependent records first before deleting the parent record. for that you can add below direct sql query for check parent dependency and delete it.

$connection = $resource->getConnection(); $valueId = '1913671126'; // Example value_id, replace with dynamic fetching logic try { $connection->beginTransaction(); // Delete dependent records $connection->delete( 'catalog_product_entity_media_gallery_value_video', ['value_id = ?' => $valueId] ); // Delete parent record $connection->delete( 'catalog_product_entity_media_gallery', ['value_id = ?' => $valueId] ); $connection->commit(); } catch (\Exception $e) { $connection->rollBack(); throw $e; } 
0

@Vito Lanave

Hey, please look at the following steps:

  1. Check Cron Configuration
  2. Check Cron Schedule
  3. Check Cron Logs
  4. Check File Permissions
  5. Review Cron Job Code
  6. Check Log Errors
  7. Run Cron Manually
  8. Check PHP Version && Clear Cache

Thank You!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.