The related product group feature provides users to group of related products of the main product in order to get the desired outcome of main and related product combination. It uses a lookup table to maintain the group information and its associated products. A Product modeler or system administrator needs to implement by putting all data needed for related product group in a single table which was defined as per the specifications as mentioned in Section 10.1 and using the default implementation of retrieving the group data or related products data ( See also Section 10.3 ). The followings are steps that are required for this feature will be further explained in detail below.
- Step 1: Define the table structure to maintain the related product hierarchical structure
- Step 2: Upload the related product group data into a table via excel
- Step 3: Implement the Groovy Script
- Step 4: Upload the related product group groovy script to the Digital Sales Platform.
Step 1: Define the Table Structure to Maintain the Related Product Hierarchical Structure
In order to provide the related products list for selected main product and group hierarchy, there are two kinds of data to be maintained inside the table.
- 1.1 Main Product and Related Product
- 1.2 Group Hierarchical Data ( Optional )
Group hierarchical data is optional for the case where system does not have the navigation concept to reach the related products via group.
1.1 Main Product and Related Product Mapping
It is mandatory to define the lookup table that includes at least two lookup fields to map between Main Product and Related Product, using the onType and onAttribute properties. Main Product field and Related Product field name can be named differently. However, it is mandatory to assign onType property in lookup table to be Product and onAttribute property in lookup table to be either one of the followings depending on the needs of the system.
- objectName
- objectExternalId
- objectERPId
1.2 Group Hierarchical Data
Group code and group description fields are optional and there is no limit on having multiple levels of group if there is a group hierarchy concept for related product group. If group hierarchy concept is in use, user need to define the naming convention for group code and delimiter to extract the level information from the Group Code. For example, 001, 001-001 is a recommended group code naming convention where [-] is the delimiter to define the level of group. The group level indicator will further be used in default implementation in order to know which further group code and group name to return to UI.
The LookupTable needs to be defined in order to provide the data needed for Related Product Group concept. The table must contain the following:
- 1 Lookup field for Main Product
- 1 Lookup field for Related Product
1. Set up Lookup Table, note to set Validity and Delta Price to NO
2.Define Main Product
3.Define Related Product
4.Define simple Group Code field
5. Define Group Name field
Step 2: Upload the Data into Table
To prepare data for Main and Related Products, there are a few ways;
a. By defining the ERP ID on lookup table and lookup field and synchronize system to ERP, in order to obtain the needed data structure.
b. By using excel download and upload feature.
The example below shows the data used together with Groovy script.
Step 3: Implementing Groovy Script
Using default groovy implementation provided by the application to obtain the groups and their corresponding related products based on the table defined above. They can be divided into three categories.
- Importing necessary class
- Configuring the LookupTable Usage
- Executing the Engine and Returning Results
3.1: Importing necessary class
The followings are the classes to be import inside the groovy script.
- import com.imc.model.Product;
- import com.imc.model.RelatedProductGroup;
- import com.imc.iss.groovy.GroovyLogger;
- import com.imc.iss.groovy.lookupTable.GroovyLookupTable;
- import com.imc.iss.configuration.services.RelatedProductHierarchyEngine;
Groovy script can use [engine] variable which is an instance RelatedProductHierarchyEngine that provide the following methods
- void init(String tableName,String mainProductFieldName,String relatedProductFieldName)
- To initialize the engine about the table name used and main product field and related product
- void addGroupCodeField(String groupCodeFieldName,int levelIndicator)
- To let the engine know about the groupCodeFieldName and its corresponding level
- void addGroupNameField(String groupCodeFieldName, String groupNameFieldName)
- To map the group code field and its corresponding group name field
- void setGroupCodeDelimiter(String groupCodeDelimiter)
- To let the engine know about the naming convention of the group code
- RelatedProductGroup run()
- To execute the default java implementation based on current sales item’s product
- addResult(RelatedProductGroup relatedProductGroup)
- To add the executed results to engine
- List<RelatedProductGroup> getResults()
- To return the added executed results to user interface
3.2: Configuring the Lookup Table Usage
a. User need to initialize the Related Product Hierarchy Engine with table name, Main Product field name and Related Product field name defined in that table.
b. User need to specify the group code field and its corresponding level indication using the following method
- addGroupCodeField ([FieldName],[level indicator])
The mapping between Group Code field and the Group Description field can be defined using the following method
- addGroupNameField ([Group Code Field Name],[ Group Name Field Name].
- It is needed to call the addGroupNameField after the addGroupCodeField.
c. User need to specify the delimiter to be used in the Group Code field value using the following method.
- setGroupCodeDelimiter ("-")
3.3: Executing the engine and Returning Results
After setting up the lookup table usage, user can then activate engine to retrieve the data by calling the following method
- run()
- which returns the RelatedProductGroup object
The result returned from run() method is needed to add to a result list by using addResult([RelatedProductGroup]) method and finally, it is needed to return the result(s) from the groovy script to system using getResults();
The following is the complete example of the groovy script that is using the standard default implementation with 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(); |
Uploading the Related Product Group Groovy Script
After implementing the related product group data and groovy script, the next step is to upload the script to the Digital Sales Platform.
- Select Administration -> Master Data Management ->Groovy Script to see list of all the available groovy script end point
- Select the Groovy Script, Related Product Hierarchy – custom script to return the related product hierarchy
- Upload the Groovy Script file
- Assign the LookupTable(s) used inside the Groovy Script
- Click Save to complete the groovy script implementation for Related Product Hierarchy
Step 4: Testing the Related Product Group Implementation
To test if above implementation is correct:
- Open a quote with a product (E.g. Product A ) that is defined as a Main Product with Related Product Group table and you will see the actionable menu(...) on each line item.
- Click on the Related Products
-
Based on the sample data, selecting the Group 1.2 under Product will list related Product as Product A2 as shown below.
Comments
0 comments
Article is closed for comments.