October 21, 2013

Magento "Cannot add or update a child row" Report Event

Categories: 
Published: 21 October 2013 

Had an issue on a clients Magento site today.

The site was moved from one server to current one a few weeks back. Today our system alerted us to 500 errors being returned by the site.

Found this in the error_log
"cannot add or update a child row: a foreign key constraint fails (`db_name`.`report_event`, CONSTRA"

Fix

Using phpMyAdmin (or your favourite tool) connect to your database and check if the "report_event" table has any data in it. If no, then the below fix should get your site back up and running.


INSERT INTO `report_event_types` (`event_type_id`, `event_name`, `customer_login`) VALUES
(1, 'catalog_product_view', 1),
(2, 'sendfriend_product', 1),
(3, 'catalog_product_compare_add_product', 1),
(4, 'checkout_cart_add_product', 1),
(5, 'wishlist_add_product', 1),
(6, 'wishlist_share', 1);

If your table does have data in it, compare the rows to the above insert statement. If you are missing some info, put it in.

If all the records match, unfortunately you'll have to keep googling.

Had an issue on a clients Magento site today.

The site was moved from one server to current one a few weeks back. Today our system alerted us to 500 errors being returned by the site.

Found this in the error_log
"cannot add or update a child row: a foreign key constraint fails (`db_name`.`report_event`, CONSTRA"

Fix

Using phpMyAdmin (or your favourite tool) connect to your database and check if the "report_event" table has any data in it. If no, then the below fix should get your site back up and running.


INSERT INTO `report_event_types` (`event_type_id`, `event_name`, `customer_login`) VALUES
(1, 'catalog_product_view', 1),
(2, 'sendfriend_product', 1),
(3, 'catalog_product_compare_add_product', 1),
(4, 'checkout_cart_add_product', 1),
(5, 'wishlist_add_product', 1),
(6, 'wishlist_share', 1);

If your table does have data in it, compare the rows to the above insert statement. If you are missing some info, put it in.

If all the records match, unfortunately you'll have to keep googling.

Ben Maden

Read more posts by Ben

Leave a Reply

Your email address will not be published. Required fields are marked *

Shares