on 2022 Sep 27 11:47 PM
Hello SAP team, I have two questions regarding the "orderCodeGenerator" and its modifications.
1.-I would like to know how it works, also how it works in "cluster".
2.-There is the possibility of keeping the same cart id so that when generating the order it keeps that same cart id, and what would be the disadvantages of doing this.
Regards
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
We use this approach (order code is the same with cart code) in most of our projects since we use it mostly for as a reference on payment provider. This will not cause any DB related issue since their table are different i.e. orders and carts. The only problem could happen is when a problem / exception occurs between order creation and cart removal. In such cases, order will be generated in the table but cart will not be removed. Thus, additional order creation request will be failed since the order with the same code already exists. Other than this case, I don't think it will cause you a problem.
Easiest way to achieve this is to override DefaultCreateOrderFromCartStrategy's generateOrderCode method as below
@Override
protected String generateOrderCode(CartModel cart) {
return cart.getCode();
}And defining the spring definition
<alias alias="createOrderFromCartStrategy" name="customCreateOrderFromCartStrategy"/>
<bean id="customCreateOrderFromCartStrategy" parent="defaultCreateOrderFromCartStrategy"
class="com.custom.extension.strategy.impl.CustomCreateOrderFromCartStrategy"/>
Hope this helps,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
DB table is used to guarantee that the order/cart id is unique across the whole system even in cluster environment
cart and order will use different id in the default implementation, since both of them are based on the same key 'order_code', each time as order instance is created from a cart instance, a new id will be generated from current number range
if you hope that order will copy the id number from related cart, customization is required, but i don't think it makes sense
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.