Magento – Product ID Conflicts – SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

errorpaymentpaypalsql

I am having major issues with payment on one of my customers websites, for example when you go through PayPal Express on the confirmation page were the customer chooses there shipping method they get error "Please specify a shipping method".

I believe what is causing this is when I imported orders using a third party extension to this website, it did not update the order ID increment and keeps conflicting all the time, I have tried to update this in the database without much luck. If someone could point me in the right direction I would be really grateful.

Heres an error we got emailed.

Payment transaction failed.
Reason
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '100000109' for key 'UNQ_SALES_FLAT_ORDER_INCREMENT_ID', 
query was:
INSERT INTO `sales_flat_order` (
   `state`, `coupon_code`, `protect_code`, `shipping_description`,
   `is_virtual`, `store_id`, `customer_id`, `base_discount_amount`,
   `base_grand_total`, `base_shipping_amount`, 
   `base_shipping_tax_amount`, `base_subtotal`, `base_tax_amount`,
   `base_to_global_rate`, `base_to_order_rate`, `discount_amount`,
   `grand_total`, `shipping_amount`, `shipping_tax_amount`, 
   `store_to_base_rate`, `store_to_order_rate`, `subtotal`,
   `tax_amount`, `total_qty_ordered`, `customer_is_guest`, 
   `customer_note_notify`, `customer_group_id`, `quote_id`, 
   `base_shipping_discount_amount`, `base_subtotal_incl_tax`, 
   `shipping_discount_amount`, `subtotal_incl_tax`, `weight`, 
   `customer_dob`, `increment_id`, `applied_rule_ids`, 
   `base_currency_code`, `customer_email`, `customer_firstname`, 
   `customer_lastname`, `customer_middlename`, `customer_prefix`, 
   `customer_suffix`, `customer_taxvat`, `discount_description`, 
   `global_currency_code`, `order_currency_code`, `remote_ip`, 
   `shipping_method`, `store_currency_code`, `store_name`, 
   `x_forwarded_for`, `customer_note`, `created_at`, `updated_at`, 
   `total_item_count`, `customer_gender`, `custbalance_amount`, 
   `is_multi_payment`, `base_custbalance_amount`, `hidden_tax_amount`, 
   `base_hidden_tax_amount`, `shipping_hidden_tax_amount`, 
   `base_shipping_hidden_tax_amnt`, `shipping_incl_tax`, 
   `base_shipping_incl_tax`, `gift_message_id`
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
   ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
   ?, ?, ?, ?, ?, ?, ?, ?, ?, '2015-03-12 19:44:28', '2015-03-12 19:44:28', 
   ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)

I am using Magento 1.9

Best Answer

The order number 100000109 (i.e. increment ID or increment_id) already exists in your order table, sales_flat_order, and it's failing the order save when someone checks out because increment_ids must be unique.

First, verify that you have these order numbers you see in the error messages are indeed already present in the sales_flat_order.increment column. Then, you need to modify the eav_entity_store.increment_id value(s), so that new increment IDs will never overlap with your the already existing order numbers.

Check the maximum value in sales_flat_order.increment_id, and update eav_entity_store.increment_id with a value greater than that.