Custom ID format of order generated by hybris

Time:2020-10-24

In the project local.properties The definition is as follows:

keygen.order.code.digits=8
keygen.order.code.start=00000000
keygen.order.code.numeric=true
keygen.order.code.template=$

Custom ID format of order generated by hybris
Custom ID format of order generated by hybris

core-spring.xml:

<bean id="orderCodeGenerator" class="de.hybris.platform.servicelayer.keygenerator.impl.PersistentKeyGenerator">
<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}"/>

The results are as follows:

Custom ID format of order generated by hybris
Custom ID format of order generated by hybris

After modifying the definition, if you don’t want to restart hybris server, it can take effect immediately. Use the following java code:

import de.hybris.platform.jalo.numberseries.*
NumberSeriesManager nm = NumberSeriesManager.getInstance()
def s = nm.getNumberSeries("order_code")
println "Before: current: ${s.currentNumber} type: ${s.type} template: ${s.template}"
nm.resetNumberSeries(s.key, "777", s.type, s.template )
def s2 = nm.getNumberSeries("order_code")
println "After: current: ${s2.currentNumber} type: ${s2.type} template: ${s2.template}"

For more original articles on Jerry, please pay attention to the official account of “Wang Zixi”:
Custom ID format of order generated by hybris