You can use this API to build a hierarchy of products based on a list of parent and child pairs.

buildHierarchywebService static Apttus_Config2.CPQAdminStruct.HierarchyResponseDO buildHierarchy(Apttus_Config2.CPQAdminStruct.HierarchyRequestDO hierarchyRequestDO)

Request Parameter
hierarchyRequestDOApttus_Config2.CPQAdminStruct.HierarchyRequestDOThe hierarchy request data object.

Request Data Object - Apttus_Config2.CPQAdminStruct.HierarchyRequestDO
HierarchyDOsList<Apttus_Config2.CPQAdminStruct.HierarchyDO>the list of hierarchy data object
isCascadeGroupChangesBooleanIndicates whether to reflect the changes made to this instance of the option group to all of its sibling option groups across products.
OptionGroupIdIdThe Id of the option group.
OptionGroupIdsList <Id>The list of option group Ids to be associated with the bundle product.
ProductIdIdThe Id of the product to be the parent in the hierarchy.
ProductIdsList <Id>The list of child product Ids.
Data Object - Apttus_Config2.CPQAdminStruct.HierarchyDO
ChildOptionGroupIdIdThe Id of the child option child group.
ChildProductIdId The Id of the child product.
ParentOptionGroupIdId The Id of the parent option group.
ParentProductIdId The Id of the parent product.
Response Parameter - Apttus_Config2.CPQAdminStruct.HierarchyResponseDO
ProductOptionGroupDOApttus_Config2.CPQAdminStruct2.ProductOptionGroupDOThe parent option group data object.
SuccessBoolean Indicates whether building hierarchy was successful or not.
Data Object - Apttus_Config2.CPQAdminStruct2.ProductOptionGroupDO
ChildOptionGroupDOsList<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.
ComponentSOsList<Apttus_Config2__ProductOptionComponent__c> The list of product option components.
ProductOptionComponentDOsList<Apttus_Config2.CPQAdminStruct2.ProductOptionComponentDO>The list of product option components data objects.
ProductOptionGroupSOApttus_Config2__ProductOptionGroup__cThe sObject of the product option group.
Data Object - Apttus_Config2.CPQAdminStruct2.ProductOptionComponentDO
DefaultQuantityExpressionSOApttus_Config2__FieldExpression__cThe sObject of default quantity expression.
MaxQuantityExpressionSOApttus_Config2__FieldExpression__cThe sObject of max quantity expression
MinQuantityExpressionSOApttus_Config2__FieldExpression__cThe sObject of the product option group.
ProductOptionComponentSOApttus_Config2__ProductOptionComponent__cThe 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;

	// 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) {
	hierResponse = Apttus_Config2.CPQAdminWebService.buildHierarchy(hierRequest);
	return hierResponse.Success;