How to Configure the Order Number Range in SAP Hybris Commerce Using Groovy

If you haven't noticed already, I leverage Groovy quite a bit to configure SAP Hybris Commerce. Groovy can also be used to programatically re-define the Hybris Commerce's order number range. The OOTB Hybris order number seed value starts at zero (0), which means the first order in Hybris will normally begin at order number one (1), unless you redefine the keygen.order.code.start property in the file.

There are are certain circumstances when we need to re-define the order number range dynamically, in particular for testing purposes. This tutorial will demonstrate how to configure SAP Hybris Commerce's default order number range using Groovy.

1.  Log into Hybris Administration Console (HAC) with your admin credentials

2. Once you've logged in successfully, click on Console -> Scripting Languages

3. Copy and paste the following Groovy code into the Console window:

import de.hybris.platform.jalo.numberseries.NumberSeriesManager;

/* get the instance of the NumberSeriesManager, which manges number generation logic/data in Hybris **/
NumberSeriesManager numberSeriesManager = NumberSeriesManager.getInstance()

/* set the name of the order number series key, order_code is the Hybris OOTB order number key **/
def order_number_key = "order_code"

/*pass the the order number series key to the NumberSeriesManager's getNumberSeries function **/
def numberSeries = numberSeriesManager.getNumberSeries(order_number_key)

println "Original Order Number Seed (Start) Value: ${numberSeries.currentNumber}"

/* dynamically re-define the order number seed number */
numberSeriesManager.resetNumberSeries(numberSeries.key, "10000000", numberSeries.type, numberSeries.template )

/*re-fetch the order number seed value to confirm the resetNumberSeries method properly
set the value to 1,000,000 */
numberSeries = numberSeriesManager.getNumberSeries(order_number_key)

println "New Order Number Seed (Start) Value: ${numberSeries.currentNumber}"

Your Console should resemble the following:

4. Click on Execute

5.  Click on the Output tab, the new order Number Seed (start value) should set to 1000000

6. The tutorial is complete, now you know how to configure the order number range in SAP Hybris Commerce using Groovy.

Marc Raygoza

Marc is the Founder of
He enjoys helping others learn more about SAP Commerce Cloud (Hybris). Marc is a SAP Commerce Certified Professional and has held the role of SAP Commerce Cloud Architect at Deloitte, PwC, Brillio (a Bain Company), and Nasty Gal. Marc holds an M.S. Software Engineering from Carnegie Mellon University and a B.S. in Accountancy from California State University, Fresno. He can be reached at:

You may also like...

Popular Posts