on 2015 Apr 23 9:08 AM
How can we create different number series for carts & orders. Default behavior is when we add to cart & go for order we get cart number as 00000001 & order number as 00000002 & this goes on...And when the server is restarted the number get increased by thousand(1000)...
Pls help.
Hi Anil, You should redefine your Key generator like this
keygen.order.code.name=order_code
keygen.order.code.digits=8
keygen.order.code.start=00000001
keygen.order.code.numeric=true
keygen.order.code.template=SWC$
numberseries.cache.size.order_code=1000
<bean id="orderCodeGenerator" class="my.project.keygenerator.impl.MyPersistentKeyGenerator">
<property name="key" value="${keygen.order.code.name}"/>
<property name="digits" value="${keygen.order.code.digits}"/>
<property name="start" value="${keygen.order.code.start}"/>
<property name="numeric" value="${keygen.order.code.numeric}"/>
<property name="template" value="${keygen.order.code.template}"/>
</bean>
I hope this will help you. BR Hassan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, you need to create a generator with a different id, and using a different numberseries key, to use in the cart factory, something like this:
<bean id="cartCodeGenerator" class="de.hybris.platform.servicelayer.keygenerator.impl.PersistentKeyGenerator">
<property name="key" value="cart_code" />
<property name="digits" value="10" />
<property name="start" value="0" />
<property name="numeric" value="true" />
<property name="template" value="$" />
</bean>
Additional information -
numberseries.cache.size.order_code=1000
The number generator uses the above property to cache the next possible codes in the series in order to reduce DB calls and in a clustered environment each node will have its on cache meaning a different set of codes (1000 codes) in the cache.
And since these are in memory caches, a server restart looses the cache, meaning the server gets the next number sequence from the DB which will then be = last code used + 1000
Hi Hasan/Experts,
I dont see the bean - orderCodeGenerator present in saporderexchange-spring.xml, Do I have to add this in my saporderexchange extension spring.xml file?
Or please let me know what configurations need to be done to get this. I am getting error while running spring.getBean("orderCodeGenerator").reset(); from HAC. Can you please help?
Below is the error -
Script execution has failed [reason: Sourced file: inline evaluation of: ``spring.getBean("orderCodeGenerator").reset();'' : Method Invocation reset : at Line: 1 : in file: inline evaluation of: ``spring.getBean("orderCodeGenerator").reset();'' : .reset ( ) Target exception: de.hybris.platform.jalo.JaloInvalidParameterException: did not find number series order_code - cannot reset to [order_code,1,5000000][HY-0] in inline evaluation of: ``spring.getBean("orderCodeGenerator").reset();'' at line number 1]
That is done in spring. Reconfigure the cartFactory to use a new order generator instead of "orderCodeGenerator".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christoph,
Created the generator as cartCodeGenerator as you mentioned & referred the same in CartFactory as below:
<bean id="defaultCartFactory" class="de.hybris.platform.order.impl.DefaultCartFactory">
<property name="keyGenerator" ref="cartCodeGenerator"/>
<property name="modelService" ref="modelService"/>
<property name="userService" ref="userService"/>
<property name="commonI18NService" ref="commonI18NService"/>
</bean>
Still not able to get different series for Carts, getting the same series used for orders.
Hi Christoph,
Thanks for suggestion. I am able to generate the different numeric series for carts & orders. I would like to know how to create alpha-numeric series. I had tried with the following local properties
keygen.order.code.name=order_code keygen.order.code.digits=8 keygen.order.code.start=1000000 keygen.order.code.numeric=true keygen.order.code.template=ACC-$-DE
But not able to create alpha numeric series. Request your help for the same.
I found that I had this same problem. I updated the defaultCartFactory from order-spring.xml as specified, but I found out that the cartFactory alias was being overwritten by commerceCartFactory from commerceservices-spring.xml. So I modified the commerceCartFactory bean to use the cartCodeGenerator instead of orderCodeGenerator.
Hi Christop Meyer, I tried this but still getting the numeric value for the SO, I am looking for alpha numeric as per the code above, I believe it will generate SWC00000001 like this. Can you help me posting this class MyPersistentKeyGenerator? or am I missing something here?
Thanks for your sharing...
User | Count |
---|---|
11 | |
1 | |
1 | |
1 | |
1 | |
1 | |
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.