{"id":694,"date":"2021-01-18T13:33:34","date_gmt":"2021-01-18T13:33:34","guid":{"rendered":"http:\/\/morecpq.com\/?p=694"},"modified":"2021-01-18T13:36:28","modified_gmt":"2021-01-18T13:36:28","slug":"cpq-feature-recommended-products","status":"publish","type":"post","link":"https:\/\/morecpq.com\/index.php\/2021\/01\/18\/cpq-feature-recommended-products\/","title":{"rendered":"CPQ Feature!  Recommended Products!"},"content":{"rendered":"\n<p>I can not tell you how many times someone has requested to see recommended products after adding a bunch of stuff to the line editor.  It&#8217;s probably in the top ten functionality requests.  I always have to implement some sort of lookup product rule based on their criteria for the recommendations.<\/p>\n\n\n\n<p>Well look no further!  There&#8217;s actually a hook built in now that you can attach to.  It needs: a Custom Object, an APEX class, a Package Setting, and a Custom Action record update.  All are below.<\/p>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Custom Object<\/span><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"940\" height=\"592\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-2-1024x645.png?resize=940%2C592\" alt=\"\" class=\"wp-image-695\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-2.png?resize=1024%2C645&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-2.png?resize=300%2C189&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-2.png?resize=768%2C484&amp;ssl=1 768w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-2.png?resize=1536%2C967&amp;ssl=1 1536w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-2.png?resize=2048%2C1290&amp;ssl=1 2048w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-2.png?w=1880&amp;ssl=1 1880w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/figure>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">APEX Class<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global class RecommendedProductsPlugin implements SBQQ.ProductRecommendationPlugin {\n    global PricebookEntry&#91;] recommend(SObject quote, List&lt;SObject&gt; quoteLines) {\n        \/\/ Get the price book Id of the quote\n        Id pricebookId = (Id)quote.get('SBQQ__PriceBookId__c');\n        \n        \/\/ Get Ids of all products in the quote\n        Id&#91;] productIdsInQuote = new Id&#91;0];\n        for (SObject quoteLine : quoteLines) {\n            Id productId = (Id)quoteLine.get('SBQQ__Product__c');\n            productIdsInQuote.add(productId);\n        }\n        \n        \/\/ Query the recommendation custom object records of all products in quote.\n        ProductRecommendation__c&#91;] recommendations = &#91;\n            SELECT RecommendedProduct2Id__c\n            FROM ProductRecommendation__c\n            WHERE Product2Id__c IN :productIdsInQuote];\n        \n        \/\/ Get Ids of all recommended products\n        Id&#91;] recommendedProductIds = new Id&#91;0];\n        for(ProductRecommendation__c recommendation : recommendations) {\n            recommendedProductIds.add(recommendation.RecommendedProduct2Id__c);\n        }\n        \n        \/\/ Query the price book entries of the above recommended products\n        PricebookEntry&#91;] priceBookEntries = &#91;\n            SELECT Id, UnitPrice, Pricebook2Id, Product2Id, Product2.Name, Product2.ProductCode\n            FROM PricebookEntry\n            WHERE Product2Id IN :recommendedProductIds AND Pricebook2Id = :pricebookId];\n        return priceBookEntries;\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Package Setting<\/span><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-3-1024x333.png?resize=912%2C297\" alt=\"\" class=\"wp-image-698\" width=\"912\" height=\"297\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-3.png?resize=1024%2C333&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-3.png?resize=300%2C98&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-3.png?resize=768%2C250&amp;ssl=1 768w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-3.png?resize=1536%2C499&amp;ssl=1 1536w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-3.png?resize=2048%2C666&amp;ssl=1 2048w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-3.png?w=1880&amp;ssl=1 1880w\" sizes=\"(max-width: 912px) 100vw, 912px\" \/><\/figure>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Custom Action Record Update<\/span><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"940\" height=\"320\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-4-1024x349.png?resize=940%2C320\" alt=\"\" class=\"wp-image-700\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-4.png?resize=1024%2C349&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-4.png?resize=300%2C102&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-4.png?resize=768%2C262&amp;ssl=1 768w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-4.png?resize=1536%2C523&amp;ssl=1 1536w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-4.png?resize=2048%2C697&amp;ssl=1 2048w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-4.png?w=1880&amp;ssl=1 1880w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/figure>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Notes<\/span><\/strong><\/p>\n\n\n\n<p><strong>Note<\/strong>: Shows a max 2000 records.  To sort the records, add a Sort number field to your custom object and update the APEX code to sort by the Sort field.<br><strong>Note<\/strong>: Doesn&#8217;t Support Large Quoting Experience.<br><strong>Note<\/strong>: The Recommended Products screen uses the Search Results field set on the Product object for its columns.<br><strong>Note<\/strong>: Supports field level security on fields included in the plugin. Users will not see fields from the Search Results field set they don&#8217;t have access to.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-5-1024x282.png?resize=858%2C237\" alt=\"\" class=\"wp-image-702\" width=\"858\" height=\"237\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-5.png?resize=1024%2C282&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-5.png?resize=300%2C83&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-5.png?resize=768%2C211&amp;ssl=1 768w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-5.png?resize=1536%2C423&amp;ssl=1 1536w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-5.png?w=2014&amp;ssl=1 2014w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-5.png?w=1880&amp;ssl=1 1880w\" sizes=\"(max-width: 858px) 100vw, 858px\" \/><\/figure>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Demo<\/span><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-6-1024x662.png?resize=759%2C491\" alt=\"\" class=\"wp-image-709\" width=\"759\" height=\"491\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-6.png?resize=1024%2C662&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-6.png?resize=300%2C194&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-6.png?resize=768%2C497&amp;ssl=1 768w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-6.png?resize=1536%2C994&amp;ssl=1 1536w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/01\/image-6.png?w=1722&amp;ssl=1 1722w\" sizes=\"(max-width: 759px) 100vw, 759px\" \/><\/figure>\n\n\n\n<p><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.cpq_dev_api.meta\/cpq_dev_api\/cpq_recommended_products_plugin.htm\" target=\"_blank\" rel=\"noreferrer noopener\">Reference<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I can not tell you how many times someone has requested to see recommended products after adding a bunch of stuff to the line editor. It&#8217;s probably in the top ten functionality requests. I always have to implement some sort of lookup product rule based on their criteria for the recommendations. Well look no further! &hellip;<br \/><a href=\"https:\/\/morecpq.com\/index.php\/2021\/01\/18\/cpq-feature-recommended-products\/\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">CPQ Feature!  Recommended Products!<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-694","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/comments?post=694"}],"version-history":[{"count":12,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/694\/revisions"}],"predecessor-version":[{"id":712,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/694\/revisions\/712"}],"wp:attachment":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/media?parent=694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/categories?post=694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/tags?post=694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}