Retrieves List of Parent Product
You can use this API to retrieve the list of product Ids that are parents to the given product.
|
API |
Signature |
|---|---|
| getParentProducts |
webService static List getParentProducts(String productId) |
|
Request Parameter |
||
|---|---|---|
|
Name |
Type |
Description |
| productId | String |
The id product for which you want to retrieve the parent product. |
|
Response Parameter |
||
|---|---|---|
|
Name |
Type |
Description |
| parentProductIDs | List |
The list of parent products |
Code Sample
The below sample code retrieves the parent products of a given product.
public List<Id> getParentProducts(String productName) {
// get child and parent products and option group
Product2 childProduct = [SELECT Id FROM Product2 WHERE Name = :productName LIMIT 1];
// retrieve product IDs
List<ID> parentProductIds = CPQAdminWebService.getParentProducts(childProduct.Id);
return parentProductIds;
}
