This is used to retrieve products, based on product IDs, and compare them side by side. This is typically done from the Product Catalog, to decide between products before adding them to the cart.

Prerequisite: You must set up feature sets and associate them with the products you want to compare. There is no API for this process—you must configure this in your org. For more information, refer to the CPQ on Salesforce Administrator Guide topic Configuring Product Comparison.


APISignature
compareProducts

webService static List compareProducts(Apttus_CPQApi.CPQ.FeatureInfoRequestDO request)



Parameters
NameTypeDescription
requestApttus_CPQApi.CPQ.FeatureInfoRequestDOThe request data object.
Request Data Object - Apttus_CPQApi.CPQ.FeatureInfoRequestDO
FieldTypeDescription
productIdsList<ID>The list of Ids of the product you want to compare.
Response Data Object - Apttus_CPQApi.CPQ.FeatureInfoResponseDO
FieldTypeDescription
FeatureInfosList<Apttus_CPQApi.FeatureSupport.FeatureInfo>This returns the list of features for each of the products included in the comparison.
ProductIdIDID of the products, which have a feature set to be compared.
Data Object - Apttus_CPQApi.FeatureSupport.FeatureInfo

Field

Type

Description

ProductFeatureSet

FeatureSet

Associated Product Feature Set

ProductFeatureSOId

Id

Id of associated ProductFeature__c Salesforce Object

Data Object - Apttus_CPQApi. FeatureSupport.FeatureSet

Field

Type

Description

Description

String

Description of associated product feature set

Features

List<Apttus_CPQApi. FeatureSupport.ProductFeatureValue>

List of associated feature values

FeatureSetSOId

Id

Id of associated Apttus_Config2__FeatureSet__cSalesforce Object

Name

String

Name of the associated Product Feature Set

Sequence

Decimal

Order of the feature set

Data Object - Apttus_CPQApi.FeatureSupport.ProductFeatureValue

Field

Type

Description

FeatureSOId

Id

ID of the associated feature set.

IsIncluded

Boolean

Whether it is included

Name

String

Name of the feature

ProdFeatureValueSOId

Id

Product Feature Value SoId

ProdId

Id

ID of the product.

Sequence

Decimal

The feature display sequence

Value

String

Product Feature Value


Code Sample

The sample below enables you to fetch the IDs of the selected products. Two or more products should be selected to enable comparison. After the user selects two or more products such as a Laptop from different vendors, invoke this API.


public List<CPQ.FeatureInfoResponseDO> compareProducts(List<ID>productIds)
{

	//Prompt appropriate error message validation message when the productIds parameter has less than two products.

	if(productIds.size()< 2)
	{
		System.debug('Please select atleast two products to compare.');
		return null;
	}

	//If two or more products are selected execute the code below

	else{
		Apttus_CPQApi.CPQ.FeatureInfoRequestDO request = new Apttus_CPQApi.CPQ.FeatureInfoRequestDO();
		request.ProductIds = productIds;
		//Invoke the compare products API
		List<Apttus_CPQApi.CPQ.FeatureInfoResponseDO> response = Apttus_CPQApi.CPQWebService.compareProducts(request);
		return	response;
		}
}
CODE


Code sample

The sample code below allows you to create a table in a Visualforce page to display the compared products:
 

'compareFeatureSets' in Visualforce code is the getter variable which hold the
response from compareProducts apex method.


Visualforce code


<!-- Compare Products Panel -->

<apex:outputPanel layout="block" Id="compareProductsPanel" styleClass="grid-2-13 clearfix compareProductsPanel">
<table>
	<apex:repeat var="featureSetName" value="{!compareFeatureSets}">
		<tr> <th data-priority="1" colspan="{!colSpan}"><h4>{!featureSetName}</h4></th></tr>
	<apex:repeat var="featureValue" value="{!compareFeatureSets [featureSetName][0].productFeatureSet.features}">
	<apex:outputPanel layout="none"rendered="{!hasIncludedProduct[compareFeatureSets[featureSetName][0].productFeatureSet.featureSetSOId]}">
		<tr><th class="label">{!featureValue.Name}</th>
			<apex:repeat var="product" value="{!productIds}">
			<apex:repeat var="prodFeatureInfo" value="{!productFeatureInfosResponse[product]}">
			<apex:outputPanel layout="none" rendered="{!prodFeatureInfo.productFeatureSet.Name == featureSetName}">
			<apex:repeat var="prodFeatureValue" value="{!prodFeatureInfo.productFeatureSet.features}">
			<apex:outputPanel layout="none" rendered="{!prodFeatureValue.featureSOId == featureValue.featureSOId && prodFeatureValue.isIncluded}">
				<td style="border:1px #CCCCCC solid;">{!prodFeatureValue.Value}</td>
			</apex:outputPanel>
			<apex:outputPanel layout="none" rendered="{!prodFeatureValue.featureSOId == featureValue.featureSOId && NOT (prodFeatureValue.isIncluded)}">
				<td style="border:1px #CCCCCC solid;"></td>
			</apex:outputPanel>
			</apex:repeat>
			</apex:outputPanel>
			</apex:repeat>
			</apex:repeat>
		</tr>
	</apex:outputPanel>
	</apex:repeat>
	</apex:repeat>
</table>
</apex:outputPanel>
CODE

Integration Details

Use the following information in your integrations with Apttus CPQ Web Services API. Refer to Integrating Apttus with External Systems for information on how to get started.

API Prerequisites

None.

Response/Request XML

Example Request

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:cpq="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQWebService"
    xmlns:cpq1="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQ">
    <soapenv:Header>
        <cpq:SessionHeader>
            <cpq:sessionId>00DZ000000NAEIA!ASAAQHmIRqgn4R9Oi1yQjWTIVk4UZmsDe_.eK0Z9z6qLij7Tu.L_Yo8dRA_p8OmhKMeRs4uzCZTadIgQ9fEbDKciXEQYRyaA</cpq:sessionId>
        </cpq:SessionHeader>
    </soapenv:Header>
    <soapenv:Body>
        <cpq:compareProducts>
            <cpq:request>
                <cpq1:ProductIds>01ti0000006iMl3</cpq1:ProductIds>
                <cpq1:ProductIds>01ti0000006iMl8</cpq1:ProductIds>
            </cpq:request>
        </cpq:compareProducts>
    </soapenv:Body>
</soapenv:Envelope>

XML

Example Response

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQWebService"
    xmlns:FeatureInfoResponseDO="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQ"
    xmlns:FeatureInfo="http://soap.sforce.com/schemas/class/Apttus_CPQApi/FeatureSupport"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <compareProductsResponse>
            <result>
                <FeatureInfoResponseDO:FeatureInfos>
                    <FeatureInfo:ProductFeatureSet>
                        <FeatureInfo:Description xsi:nil="true"/>
                        <FeatureInfo:Features>
                            <FeatureInfo:FeatureSOId>a1wi0000000jcV3AAI</FeatureInfo:FeatureSOId>
                            <FeatureInfo:IsIncluded>true</FeatureInfo:IsIncluded>
                            <FeatureInfo:Name>AutoCPQ951Feature1</FeatureInfo:Name>
                            <FeatureInfo:ProdFeatureValueSOId>a1zi0000000WsYeAAK</FeatureInfo:ProdFeatureValueSOId>
                            <FeatureInfo:ProdId>01ti0000006iMl3AAE</FeatureInfo:ProdId>
                            <FeatureInfo:Sequence>1</FeatureInfo:Sequence>
                            <FeatureInfo:Value>No</FeatureInfo:Value>
                        </FeatureInfo:Features>
                        <FeatureInfo:Features>
                            <FeatureInfo:FeatureSOId>a1wi0000000jcV4AAI</FeatureInfo:FeatureSOId>
                            <FeatureInfo:IsIncluded>true</FeatureInfo:IsIncluded>
                            <FeatureInfo:Name>AutoCPQ951Feature1</FeatureInfo:Name>
                            <FeatureInfo:ProdFeatureValueSOId>a1zi0000000WsYfAAK</FeatureInfo:ProdFeatureValueSOId>
                            <FeatureInfo:ProdId>01ti0000006iMl3AAE</FeatureInfo:ProdId>
                            <FeatureInfo:Sequence>2</FeatureInfo:Sequence>
                            <FeatureInfo:Value>Yes</FeatureInfo:Value>
                        </FeatureInfo:Features>
                        <FeatureInfo:FeatureSetSOId>a1vi0000000psEiAAI</FeatureInfo:FeatureSetSOId>
                        <FeatureInfo:Name>AutoCPQ951FeatureSet</FeatureInfo:Name>
                        <FeatureInfo:Sequence>1</FeatureInfo:Sequence>
                    </FeatureInfo:ProductFeatureSet>
                    <FeatureInfo:ProductFeatureSOId xsi:nil="true"/>
                </FeatureInfoResponseDO:FeatureInfos>
                <FeatureInfoResponseDO:ProductId>01ti0000006iMl3AAE</FeatureInfoResponseDO:ProductId>
            </result>
            <result>
                <FeatureInfoResponseDO:FeatureInfos>
                    <FeatureInfo:ProductFeatureSet>
                        <FeatureInfo:Description xsi:nil="true"/>
                        <FeatureInfo:Features>
                            <FeatureInfo:FeatureSOId>a1wi0000000jcV3AAI</FeatureInfo:FeatureSOId>
                            <FeatureInfo:IsIncluded>true</FeatureInfo:IsIncluded>
                            <FeatureInfo:Name>AutoCPQ951Feature1</FeatureInfo:Name>
                            <FeatureInfo:ProdFeatureValueSOId>a1zi0000000WsYjAAK</FeatureInfo:ProdFeatureValueSOId>
                            <FeatureInfo:ProdId>01ti0000006iMl8AAE</FeatureInfo:ProdId>
                            <FeatureInfo:Sequence>1</FeatureInfo:Sequence>
                            <FeatureInfo:Value>Yes</FeatureInfo:Value>
                        </FeatureInfo:Features>
                        <FeatureInfo:Features>
                            <FeatureInfo:FeatureSOId>a1wi0000000jcV4AAI</FeatureInfo:FeatureSOId>
                            <FeatureInfo:IsIncluded>true</FeatureInfo:IsIncluded>
                            <FeatureInfo:Name>AutoCPQ951Feature1</FeatureInfo:Name>
                            <FeatureInfo:ProdFeatureValueSOId>a1zi0000000WsYkAAK</FeatureInfo:ProdFeatureValueSOId>
                            <FeatureInfo:ProdId>01ti0000006iMl8AAE</FeatureInfo:ProdId>
                            <FeatureInfo:Sequence>2</FeatureInfo:Sequence>
                            <FeatureInfo:Value>No</FeatureInfo:Value>
                        </FeatureInfo:Features>
                        <FeatureInfo:FeatureSetSOId>a1vi0000000psEiAAI</FeatureInfo:FeatureSetSOId>
                        <FeatureInfo:Name>AutoCPQ951FeatureSet</FeatureInfo:Name>
                        <FeatureInfo:Sequence>1</FeatureInfo:Sequence>
                    </FeatureInfo:ProductFeatureSet>
                    <FeatureInfo:ProductFeatureSOId xsi:nil="true"/>
                </FeatureInfoResponseDO:FeatureInfos>
                <FeatureInfoResponseDO:ProductId>01ti0000006iMl8AAE</FeatureInfoResponseDO:ProductId>
            </result>
        </compareProductsResponse>
    </soapenv:Body>
</soapenv:Envelope>
XML