cancel
Showing results for 
Search instead for 
Did you mean: 

Can I give my own order number to a hybris order or should it always be cart code.

pavan-yvs-1
Explorer
0 Kudos
89

Hi,

We have some OCC integration where another system can place order in hybris via v2 webservices.
They would like to provide their own order number.
Can anyone please let me know if it is possible to overwrite the order number generated by hybris or create the order with the number they provide instead of generating a new one.

Thanks in advance!

Accepted Solutions (0)

Answers (2)

Answers (2)

Harish_Vatsa
Active Contributor
0 Kudos

Hi,

2 ways to do this : 

1. If your external system has a sequence you can create that sequence using the keygenerator in hybris.

de.hybris.platform.servicelayer.keygenerator.impl.PersistentKeyGenerator
keygen.ordernumber.code.name=yourOrderNumberName
keygen.ordernumber.code.digits=8
keygen.ordernumber.code.start=30000000
keygen.ordernumber.code.type=numeric
keygen.ordernumber.code.template=$
 
2. You can write the order prepare interceptor to set the code specifically.
 

 

mansurarisoy
Contributor
0 Kudos

My suggestion would be to store the order code from the external system in a separate column (e.g., externalOrderCode) and search using this column in FlexibleSearch when needed. Additionally, you should add an index to improve the query's performance.

Updating the code attribute of an Order is acceptable as long as it does not conflict with the order code number series. 

I assume you are using the standard flow since you mentioned v2 web services. In the standard flow, where you create a cart, add products to the cart, and place an order, SAP Commerce generates two codes: one for the cart and one for the order. While you can update the code attribute after order creation with the external ID, I believe generating two codes in this scenario is unnecessary. To avoid this, I would customize DefaultCartFactory and DefaultCreateOrderFromCartStrategy to prevent code generation when the cart and order are created by an external system.

Hope this helps,