cancel
Showing results for 
Search instead for 
Did you mean: 

Single order sequence for multiple Magento stores

SOLVED

Single order sequence for multiple Magento stores

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?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Single order sequence for multiple Magento stores

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.

View solution in original post

3 REPLIES 3

Re: Single order sequence for multiple Magento stores

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.

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"

Re: Single order sequence for multiple Magento stores

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.

Re: Single order sequence for multiple Magento stores

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.