Skip to main content
ErrorsMagento

Magento – Integrity constraint violation: 1062 Duplicate entry

By June 2, 2016No Comments

A client recently called with the issue that their website had gone down with the error ‘magento SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry’. They had been updating product data within Magento admin, when the frontend went down. They were still able to access the admin area of the website.

Solution: Magento – Integrity constraint violation

It seems that Magento was trying to add some data (which already existed) and as it couldn’t overwrite it, got stuck. This error is more common found when migrating / importing large amounts of data, where there is a discrepancy between the table log entries. The quickest way to solve this is to run a maintenance script that empties / truncates many of the visitor log tables that build up over time. This is usually run by a scheduled cron job, keeping the site quick and optimised.

If you don’t have a maintenance script, you can manually truncate the log tables by running SQL like the below within your Magento database in phpMyAdmin.

TRUNCATE dataflow_batch_export ; 
TRUNCATE dataflow_batch_import ; 
TRUNCATE log_customer ; 
TRUNCATE log_quote ; 
TRUNCATE log_summary ; 
TRUNCATE log_summary_type ; 
TRUNCATE log_url ; 
TRUNCATE log_url_info ; 
TRUNCATE log_visitor ; 
TRUNCATE log_visitor_info ; 
TRUNCATE log_visitor_online ; 
TRUNCATE report_event ;

If you have regular issues with you Magento store, we also provide Magento maintenance and bug fixing help.

Andrew Taylor

A senior UI designer with over 25 years of web design and web development experience working for some of the largest companies in the UK. An expert in all things Magento and WordPress.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.