Recommended Products Plugin
Product Configuration Initializer for Guided Selling
Product Search Executor for Guided Selling
Document Store Plugin
Custom Action Plugin
Salesforce CPQ Electronic Signature Plugin
Previous Versions
Use the Recommended Products plugin to recommend related products based on the existing products on a quote.
| Required Editions |
|---|
| Available in: Salesforce CPQ Winter ‘21 and later |
The Recommended Products plugin lets customers use their own product recommendation service in Salesforce CPQ, together with product search, search filters, favorites, and guided selling.
With the Recommended Products plugin, sales reps can see a list of recommended products while they are creating their quote. By making relevant products easier to find, the quoting process is more efficient, and sales reps can sell more products.
Sample use cases of the Recommended Products plugin include:
Complete these steps to implement the Recommended Products plugin:
1global interface ProductRecommendationPlugin {
2 PricebookEntry[] recommend(SObject quote, List<SObject> quoteLines);
3}This method takes quote and quote lines as arguments, and it outputs an ordered list of recommended price book entries. If at runtime the plugin input is missing a field required for your implementation, add it to the ReferencedFields field set on the corresponding object.
Add your plugin’s class name on the Plugins tab in Settings.

Note
Add products to a quote and click the Add Recommendations custom action.

Salesforce calls your plugin implementation class and obtains an ordered list of PricebookEntry sObjects. These sObjects are then displayed on the Recommended Products page.

recommend()
Description
Returns the product recommendations.
Parameters
| Param | Type | Description |
|---|---|---|
| quote | SBQQ__Quote__c | Current quote object |
| quoteLines | List<SBQQ__QuoteLine__c> | Current quote lines of the quote. |
Return Values
PricebookEntry[ ] : Ordered list of PricebookEntry SObjects.
If your plugin throws an exception, the error shows on the Recommendations Lookup page. To show that the plugin implementation throws the error, the error message shows “Plugin Error:” as a prefix followed by the message from the exception.
When you implement the Recommended Products plugin, you can create your own recommendation engine or use a third-party recommendation service. Store the product recommendations in your org in a custom object. Then, query the recommendations in the custom object from in the recommend() method of your plugin.
In this example, the name of the custom object that stores recommendations is ProductRecommendation__c.
1// Create your own Custom Object to store your product recommendations
2ProductRecommendation__c {
3 Id Product2Id__c,
4 Id RecommendedProduct2Id__c,
5}1global class ProductRecommendationPluginJH implements SBQQ.ProductRecommendationPlugin{
2global PricebookEntry[] recommend(SObject quote, List<SObject> quoteLines) {
3 System.debug('ProductRecommendationPluginJH');
4 // Get the price book Id of the quote
5 Id pricebookId = (Id)quote.get('SBQQ__PriceBookId__c');
6 String quoteCurrency=(String)quote.get('CurrencyIsoCode');
7 // Get Ids of all products in the quote
8 Id[] productIdsInQuote = new Id[0];
9 for (SObject quoteLine : quoteLines) {
10 Id productId = (Id)quoteLine.get('SBQQ__Product__c');
11 productIdsInQuote.add(productId);
12 }
13
14 // Query the recommendation custom object records of all products in quote.
15 ProductRecommendation__c[] recommendations = [
16 SELECT RecommendedProduct2Id__c
17 FROM ProductRecommendation__c
18 WHERE Product2Id__c IN :productIdsInQuote];
19
20 // Get Ids of all recommended products
21 Id[] recommendedProductIds = new Id[0];
22 for(ProductRecommendation__c recommendation : recommendations) {
23 recommendedProductIds.add(recommendation.RecommendedProduct2Id__c);
24 }
25 System.debug('>>>>>>>>>>>'+recommendedProductIds);
26 // Query the price book entries of the above recommended products
27 PricebookEntry[] priceBookEntries = [
28 SELECT Id, UnitPrice, Pricebook2Id, Product2Id, Product2.Name, Product2.ProductCode
29 FROM PricebookEntry
30 WHERE Product2Id IN :recommendedProductIds AND Pricebook2Id = :pricebookId AND CurrencyIsoCode=:quoteCurrency];
31
32 return priceBookEntries;
33}
34}