PDF
Download PDF
Download page Building Hierarchy of Products.
Building Hierarchy of Products
You can use this API to build a hierarchy of products based on a list of parent and child pairs.
API | Signature |
---|---|
buildHierarchy | webService static Apttus_Config2.CPQAdminStruct.HierarchyResponseDO buildHierarchy(Apttus_Config2.CPQAdminStruct.HierarchyRequestDO hierarchyRequestDO) |
Request Parameter | ||
---|---|---|
Name | Type | Description |
hierarchyRequestDO | Apttus_Config2.CPQAdminStruct.HierarchyRequestDO | The hierarchy request data object. |
Request Data Object - Apttus_Config2.CPQAdminStruct.HierarchyRequestDO | ||
---|---|---|
Name | Type | Description |
HierarchyDOs | List<Apttus_Config2.CPQAdminStruct.HierarchyDO> | the list of hierarchy data object |
isCascadeGroupChanges | Boolean | Indicates whether to reflect the changes made to this instance of the option group to all of its sibling option groups across products. |
OptionGroupId | Id | The Id of the option group. |
OptionGroupIds | List <Id> | The list of option group Ids to be associated with the bundle product. |
ProductId | Id | The Id of the product to be the parent in the hierarchy. |
ProductIds | List <Id> | The list of child product Ids. |
Data Object - Apttus_Config2.CPQAdminStruct.HierarchyDO | ||
---|---|---|
Name | Type | Description |
ChildOptionGroupId | Id | The Id of the child option child group. |
ChildProductId | Id | The Id of the child product. |
ParentOptionGroupId | Id | The Id of the parent option group. |
ParentProductId | Id | The Id of the parent product. |
Response Parameter - Apttus_Config2.CPQAdminStruct.HierarchyResponseDO | ||
---|---|---|
Field | Type | Description |
ProductOptionGroupDO | Apttus_Config2.CPQAdminStruct2.ProductOptionGroupDO | The parent option group data object. |
Success | Boolean | Indicates whether building hierarchy was successful or not. |
Data Object - Apttus_Config2.CPQAdminStruct2.ProductOptionGroupDO | ||
---|---|---|
Field | Type | Description |
ChildOptionGroupDOs | List<Apttus_Config2.CPQAdminStruct2.ProductOptionGroupDO> | The list of child option group data object. |
ChildProductOptionGroupSOs | List<Apttus_Config2__ProductOptionGroup__c> | The list of child product option groups. |
ComponentSOs | List<Apttus_Config2__ProductOptionComponent__c> | The list of product option components. |
ProductOptionComponentDOs | List<Apttus_Config2.CPQAdminStruct2.ProductOptionComponentDO> | The list of product option components data objects. |
ProductOptionGroupSO | Apttus_Config2__ProductOptionGroup__c | The sObject of the product option group. |
Data Object - Apttus_Config2.CPQAdminStruct2.ProductOptionComponentDO | ||
---|---|---|
Field | Type | Description |
DefaultQuantityExpressionSO | Apttus_Config2__FieldExpression__c | The sObject of default quantity expression. |
MaxQuantityExpressionSO | Apttus_Config2__FieldExpression__c | The sObject of max quantity expression |
MinQuantityExpressionSO | Apttus_Config2__FieldExpression__c | The sObject of the product option group. |
ProductOptionComponentSO | Apttus_Config2__ProductOptionComponent__c | The sObject of the product option component. |
Code Sample
The below sample code demonstrates how to build a hierarchy on parent and child products.
/**
* The below method accepts parent productname and list of option child products and categoryhierarchy name as input and return true or false as status of the build.
*/
public Boolean buildHierarchy(String parentProductName, List<String> optionProducts, String categoryHierarchyName)
{
Apttus_Config2.CPQAdminStruct.HierarchyDO hierDO = new Apttus_Config2.CPQAdminStruct.HierarchyDO();
Apttus_Config2.CPQAdminStruct.HierarchyRequestDO hierRequest = new Apttus_Config2.CPQAdminStruct.HierarchyRequestDO();
Apttus_Config2.CPQAdminStruct.HierarchyResponseDO hierResponse;
List< Apttus_Config2__ProductOptionComponent__c> poc;
// STEP 1 - Get bundle product and options
Product2 bundleProduct = [SELECT Id, Name
FROM Product2
WHERE Name = :parentProductName
LIMIT 1];
Product2 options = [SELECT Id, Name
FROM Product2
WHERE Name IN : optionProducts];
// STEP 2 - Get an option group to create a bundle with the 3 options from above
Apttus_Config2__ ClassificationHierarchy__c optionGroup = [SELECT Id, Name
FROM Apttus_Config2__ ClassificationHierarchy__c
WHERE Name = :categoryHierarchyName
LIMIT 1];
// STEP 3 - Create Bundle by associating Option Group and Product
hierRequest.ProductId = bundleProduct.Id;
hierRequest.OptionGroupIds.add(optionGroup.Id);
// send request and save response
hierResponse = Apttus_Config2.CPQAdminWebService.buildHierarchy(hierRequest);
// STEP 4 - Add options to the newly created bundle
hierRequest = new Apttus_Config2.CPQAdminStruct.HierarchyRequestDO();
hierRequest.ProductId = bundleProduct.Id;
hierRequest.OptionGroupId = pog[0].Id;
for (Product2 option : options) {
hierRequest.ProductIds.add(option.Id);
}
hierResponse = Apttus_Config2.CPQAdminWebService.buildHierarchy(hierRequest);
return hierResponse.Success;
}
CODE