0

After running the migration I find myself unable to place orders.

After some digging the error that is thrown is the one in the title:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '100019997-1' for key 'SALES_ORDER_INCREMENT_ID_STORE_ID

On sales_order there is increment_id value. My highest value is 100032938 but when the orderRepository saves the new order somehow 100019997 is generated. Now I have an order that already has that value and the increment_id column is an index which means unique values.

Deleting the existing order is not an option nor is truncating the sales_order table.

My question is how does Magento come up with this value 100019997. I know that the first digit is he store id and I found information that the other number 199997 is taken from sequence_order_1 table and the zeros are added by some formula. In the sequence_order_1 I have a value that is in the thirty thousands.

I've also tried. Cache cleaning and reindexing.

How can I make Magento or the DB (depending of who is responsible) to generate a valid increment_id when placing orders?

Any tips or pointers are appreciated. Thanks

PS: I've tried this with no success

  1. Open MySQL database of your Magento 2 store with the help of phpMyAdmin.
  2. Find the 'sequence_order_1' table . Note, that this table is located in the database itself, not in the 'information_schema'.
  3. Hit the 'Operations' tab and edit the necessary 'increment_id' number under it.
  • Did you manage to get a fix for this? – coderunner Feb 2 '18 at 10:38
  • I was migrating a db from M1 to M2. High volume of customers on M1. Deleted customers using direct sql. Existing quotes corresponding to that customers were not deleted. So I had a corrupt database. When placing a new order an existing quote was loaded. Magento took that pair of values from that existing quote. This was causing my problem. Fixed it bringing back the M1 database to a consistent state. Did the migration again. Everything worked fine. Not all the information I provided is 100% accurate as some time passed. You can debug the new order process and diagnose your problem. – vitoriodachef Feb 2 '18 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.