You can use this API to retrieve the product hierarchy for a given product in JSON array.

APISignature
getProductStructurewebService static Apttus_Config2.CPQAdminStruct.HierarchyResponseDO getProductStructure(Apttus_Config2.CPQAdminStruct.HierarchyRequestDO hierarchyRequestDO)
Request Parameter
NameTypeDescription
hierarchyRequestDOApttus_Config2.CPQAdminStruct.HierarchyRequestDOThe hierarchy request data object.



Request Data Object - Apttus_Config2.CPQAdminStruct.HierarchyRequestDO
NameTypeDescription
ProductIdIdThe Id of the product for which you want to retrieve hierarchy.
Response Parameter - Apttus_Config2.CPQAdminStruct.HierarchyResponseDO
FieldTypeDescription
ProductStructureJSONsList<Apttus_Config2.CPQAdminStruct.MapDO>The product hierarchy structure in JSON format.
SuccessBoolean Indicates whether building hierarchy was successful or not.
Response Data Object - Apttus_Config2.CPQAdminStruct.MapDO
FieldTypeDescription
StringKeyThe Id of the product.
StringValueThe value refers to the JSON string of the product tree.

Code Sample

The below sample code returns the product hierarchy for the given product in JSON array.


//The below method returns the entire product hierarchy for the given product in JSON Array 
public List<Apttus_Config2.CPQAdminStruct.MapDO> getProductStructure(String productName) 
{
	Product2 bundleProduct = [SELECT Id, Name
           					  FROM Product2
			           		  WHERE Name = :productName 
			           		  LIMIT 1];

	Apttus_Config2.CPQAdminStruct.HierarchyRequestDO request = new Apttus_Config2.CPQAdminStruct.HierarchyRequestDO();
	request.ProductIds.add(bundleProduct.Id);
	Apttus_Config2.CPQAdminStruct.HierarchyResponseDO response = Apttus_Config2.CPQAdminWebService.getProductStructure(request);
	
	return(response != null && response.ProductStructureJSONs.size() > 0 ? response.ProductStructureJSONs : null);
}
CODE