Hi everyone!
I'm looking for a way to customize Magento 2 order sequence in such a way that orders from each of my stores will use the same order sequence (so if order is placed in store A with order number SO001, order placed in store B will have order number SO002 and so on)
I've managed to update DB table 'sales_sequence_meta' to enable such behaviour (by setting the same sequence_table for order sequences from all of my store_ids), but when I run setup:db-data:upgrade I got "Unique constraint violation found" error despite the order sequence works as expected and without any issues (for now at least). Is there a different way (correct) way to achieve this?
Solved! Go to Solution.
I've found the issue, this problem has been resolved.
It turned out I had to use sequence_order_0 table for store_id=0, otherwise during setup:upgrade M would try to install 'order-0' entity (because of the incorrect sequence_table value this row had), which results in unique constraint violation error.
Hey @DK_dev
The Magento 2 Custom Order Number extension is suitable for your requirements.
It is a perfect tool to customize the order numbers and much useful in managing the database numbering!
Hope it helps.
I've found the issue, this problem has been resolved.
It turned out I had to use sequence_order_0 table for store_id=0, otherwise during setup:upgrade M would try to install 'order-0' entity (because of the incorrect sequence_table value this row had), which results in unique constraint violation error.
I have set for all store id_s the sequence_table for orders to sequence_order_0 but I still get the constraint error. So I'm not sure how you solved it then....
What I do now is before an setup:upgrade just briefly set the sequence_order tables to their respective stores, run the setup and set them back....but that's not the ideal solution.