Get Products
Retrieve a list of products. The list is returned based on the
Product Definition Level setting that you configured in the promotion
template.
For more information on managing promotion products at either the promotion or the tactic level, see Manage Your Products in Salesforce Help.
- Resource
-
1GET_PRODUCTS - Available version
- 55.0
- Apex Request Example
-
Before running this apex code snippet:
- Ensure the AUTHORIZATIONLISTFILTER process step is added to filter the discontinued products.
- The yearoffset value for considerdiscontinued products is either set to 1 or 2 and ensure it's provided when the process step DISCONTINUEDPRODUCTSFILTER is added.
1String salesOrg = '0001'; 2cgcloud.GetProductsCallout request = new cgcloud.GetProductsCallout(salesOrg); 3cgcloud.ProductResolutionConfiguration configuration = new cgcloud.ProductResolutionConfiguration(cgcloud.ProductResolution.ResponseFormat.DENORMALIZED /* || ProductResolution.ResponseFormat.NORMALIZED => Deprecated */); 4 5// Depending on each step we add, we will need to add some required properties to ProductResolutionConfiguration 6configuration.setSteps(new List<cgcloud.ProductResolution.ProcessStep>{ 7 // Product Source: Execute a product query with the given product filter criteria. 8 // Requires 'productfilter', 'salesorg' 9 cgcloud.ProductResolution.ProcessStep.PRODUCTQUERY, 10 //Product Source: Extract manual fixed products from the input and adds them to the result. 11 // Requires 'manualproducts' 12 cgcloud.ProductResolution.ProcessStep.MANUALPRODUCTS, 13 //Product Source: Load products for the tactic actuals defined for the tactics of the promotion defined by PromotionId. 14 // Requires 'promotionid' 15 cgcloud.ProductResolution.ProcessStep.TACTICACTUALPRODUCTS, 16 //Product Source: Load products for the payment measures defined for the tactics of the promotion defined by PromotionId. 17 // Requires 'promotionid' 18 cgcloud.ProductResolution.ProcessStep.PAYMENTPRODUCTS, 19 //Product Source: Load products for the Promotion Conditions of the promotion defined by PromotionId. 20 // Requires 'promotionid' 21 cgcloud.ProductResolution.ProcessStep.PROMOTIONCONDITIONPRODUCTS, 22 //Product Source: Load frozen products of the promotion defined by PromotionId. 23 // Requires 'promotionid' 24 cgcloud.ProductResolution.ProcessStep.FROZENPRODUCTS, 25 //Product Filter: Products those are exclude manually will be filtered out from the dynamic product resolution result. 26 // Requires 'manualproducts' 27 cgcloud.ProductResolution.ProcessStep.MANUALEXCLUDEDPRODUCTSFILTER, 28 //Product Filter: Only planning products are returned from the dynamic product resolution result. 29 // Requires 'datefrom', 'datethru', 'referencedate' (KAMStateFilter by timeframe), 30 // or 'commitdate', 'referencedate' (KAMStateFilter by commit date) 31 cgcloud.ProductResolution.ProcessStep.KAMSTATEFILTER, 32 //Product Filter: Only products that are within the global account product list of the current account are returned from the dynamic product resolution result. 33 // Requires 'accountid' 34 cgcloud.ProductResolution.ProcessStep.GLOBALACCOUNTPRODUCTLISTFILTER, 35 //Product Filter: Only products that are part of the Authorization List of the Account defined by AccountId are returned from the dynamic product resolution result. Requires 'accountid', 'datefrom', 'datethru' 36 cgcloud.ProductResolution.ProcessStep.AUTHORIZATIONLISTFILTER, 37 //Post Processing Step: Resolves the product hierarchy for the result products. 38 // Requires 'productgrouplevels', 'referenceDate' 39 cgcloud.ProductResolution.ProcessStep.RESOLVEHIERARCHY, 40 //Post Processing Step: Resolves the tactic product excludes. 41 // Requires 'tactics' 42 cgcloud.ProductResolution.ProcessStep.RESOLVETACTICPRODUCTEXCLUDES, 43 //Post Processing Step: Resolves the bill of material components 44 cgcloud.ProductResolution.ProcessStep.RESOLVEBILLOFMATERIALS, 45 //Product Filter: Discontinued products will be filtered as per year offset. Requires considerdiscontinuedproductsyearoffset 46 cgcloud.ProductResolution.ProcessStep.DISCONTINUEDPRODUCTSFILTER 47}); 48 49configuration.setAccountId('<accountId>'); 50configuration.setPromotionId('<promotion>'); 51configuration.setReferenceDate(Date.today()); 52configuration.setCommitDate(Date.today()); 53configuration.setDateFrom(Date.today().addDays(-5)); 54configuration.setDateThru(Date.today().addDays(5)); 55configuration.setProductGroupLevels('Category'); 56configuration.setProductFilter( 57 new Map<String, Object>{ 58 'cgcloud__criterion_1_product__c' => new List<Id>{ 59 '<productid>' 60 } 61}); 62configuration.setManualProducts(new List<Object>{ 63 new Map<String, Object>{ 64 65 'productid' => '<productid1>', 66 'included'=> true 67 }, 68new Map<String, Object>{ 69 'productid' => '<productid2>', 70 'included'=> false 71 } 72}) 73configuration.setKAMStateFilter('bytimeframe'); // or setKAMStateFilter('bycommitdate') 74configuration.addTactic('<tacticId1>', new List<Id>('<productid1>')); //List of excluded products 75configuration.addTactic('<tacticId2>', new List<Id>('<productid2>')); 76 77configuration.setConsiderDiscontinuedProductsYearOffset(<lookbackPeriod>); // lookback period to filter discontinued products 78 79cgcloud.GetProductsCallout.GetProductsCalloutResponse response = request.execute( 80 cgcloud.TransactionHandler.getTransactionIdentifier(), 81 configuration 82); 83 84cgcloud.GetProductsCallout.DeNormalizedCalloutProductRows result = ((cgcloud.GetProductsCallout.GetProductDeNormalizedCalloutResponse) response).getResult(); 85System.debug(JSON.serialize(result));