- 26 Nov 2024
- 3 Minutes to read
- Print
- DarkLight
Define a related product group
- Updated on 26 Nov 2024
- 3 Minutes to read
- Print
- DarkLight
Related product groups allow users to combine a main product with its related products. This feature uses a lookup table to manage the group information and its corresponding products.
To create a related product group, follow these steps:
- Create a lookup table.
- Upload the group data into the lookup table.
- Implement a Groovy script.
- Upload the Groovy script into Zilliant CPQ.
Create a lookup table
Before you begin
You need a lookup table to maintain the following data:
- Main and related product data
- (Optional.) Group hierarchical data
Main and related product data
Your lookup table must include at least two lookup columns to map the main product and the related product using the onType and onAttribute properties.
In the lookup table, you must set the onType property to the product and the onAttribute property to one of the following objects, depending on system requirements:
- objectName
- objectExternalId
- objectERPId
Group hierarchical data
Define group hierarchical data in the lookup table if your system doesn't have the navigation concept to reach related products through a group.
The group code and group description columns are optional, and there is no restriction on the number of levels if a group hierarchy concept is applied.
If the system uses a group hierarchy concept, you must define a naming convention for the group code and a delimiter to extract level information from the group code. For example, a recommended naming convention is 001, 001-001, where -
is the delimiter to indicate the group level. This group level indicator will be used in the default implementation to determine which group code and name to return to the UI.
Procedure
Upload the group data into the lookup table
There are two methods to prepare data for main and related products:
Define the ERP ID
Add the ERP ID to the lookup table and lookup column, then synchronize the system with the ERP to obtain the needed data structure.Use the Excel download and upload feature
Prepare the data in Excel, then upload it to the system.
The following image displays the data usage with a Groovy script:
Implement a Groovy script
Use Groovy to obtain the groups and their related products based on the table showed on the image in the previous section. In the Groovy script:
Import classes
Import the following classes through a Groovy script:
- com.imc.model.Product
- com.imc.model.RelatedProductGroup
- com.imc.iss.groovy.GroovyLogger
- com.imc.iss.groovy.lookupTable.GroovyLookupTable
- com.imc.iss.configuration.services.RelatedProductHierarchyEngine
A Groovy script can use the [engine] variable, for example RelatedProductHierarchyEngine, that provides the following methods:
Method | Purpose |
---|---|
void init(String tableName,String mainProductFieldName,String relatedProductFieldName) | Initialize the engine with the table name, main product column, and related product column. |
void addGroupCodeField(String groupCodeFieldName,int levelIndicator) | Inform the engine about groupCodeFieldName and its level. |
void addGroupNameField(String groupCodeFieldName, String groupNameFieldName) | Map the group code column and its corresponding group name column. |
void setGroupCodeDelimiter(String groupCodeDelimiter) | Inform the engine about the naming convention of the group code. |
RelatedProductGroup run() | Execute the default Java implementation based on the current sales item’s product. |
addResult(RelatedProductGroup relatedProductGroup) | Add executed results to the engine. |
List <RelatedProductGroup> getResults() | Return the added executed results to the user interface. |
Configure the lookup table usage
Initialize the related product hierarchy engine with the table name, main product column name, and related product column name.
Specify the group code column and its corresponding level using the following method:
addGroupCodeField ([FieldName],[level indicator])
Define the mapping between the group code column and the group description column using the following method:
addGroupNameField ([Group Code Field Name],[ Group Name Field Name]
NoteYou must call
addGroupNameField
afteraddGroupCodeField
.Specify the delimiter for the group code column using the following method:
setGroupCodeDelimiter ("-")
Execute the engine and return results
After setting up the lookup table usage:
- Use the
run()
method to activate the engine to retrieve the data. This method returns the RelatedProductGroup object. - Use the
addResult([RelatedProductGroup])
method to add the returned result to the result list. - Use the
getResults()
method to return the results to the system.
The following sample Groovy script uses the standard default implementation with a single table.
engine.init("RPH_TABLE1", "MAIN_PRODUCT ", "RELATED_PRODUCT ")
// Define the Group Code Field and Group Code Description
engine.addGroupCodeField("RPG1", 1);
engine.addGroupNameField("RPG1","RPG1_NAME ");
engine.addGroupCodeField("RPG2", 2);
engine.addGroupNameField("RPG2","RPG2_NAME");
// Set the delimiter usage in Group Code Value
engine.setGroupCodeDelimiter("-");
// Default Engine
def relatedProductGroup1 = engine.run();
engine.addResult(relatedProductGroup1);
// Return the result to Digital Sales Platform
return engine.getResults();
Upload the Groovy script
Upload your Groovy script to Zilliant CPQ.
For details about uploading and configuring Groovy scripts, read Upload a Groovy script. At Step 5, select Related Product Hierarchy - custom script to return the related product hierarchy.