You are here:
ProductEligibilityInterface
The ProductEligibilityInterface returns a filtered list of eligible products based on eligibility rules, which are usually based on account characteristics.
Type
Strongly typed
Triggered When
The ProductEligibilityInterface is triggered when the user interface must provide the current user with a list of products to select. The ProductEligibilityInterface is executed immediately after the ProductAvailabilityInterface.
Called In
The ProductEligibilityInterface is called in the ProductListUtility.cls class getProducts method.
The ProductConfigurationController checks if the CPQ Configuration Setup custom setting includeineligible is True. If True, it calls the ProductListUtility.getAllEligibilityProducts method. The ProductListUtility.getAllEligibilityProducts method gets the implementation associated with the ProductEligibilityInterface and calls the getAllEligibilityProducts method on the implementation.
The following is the data flow for Availability and Eligibility:
-
AdvProductSearchController
-
ProductListUtility.getProducts
-
ProductAvailabilityInterface
-
getAvailableProducts
-
ProductEligibilityInterface
-
getEligibleProducts
If the associated implementation uses eligibility rules, the getAllEligibilityProducts method returns a list of eligible and ineligible products with eligibility messages. If the associated implementation uses eligibility rules, the getEligibleProducts method returns only the list of eligible products with eligibility messages.
Signature
Access |
Signature |
|---|---|
global |
|
Default Implementation
The DefaultProductEligibilityImplementationDefaultProductEligibilityImplementation returns the list it received, without modification.
Other Implementations
-
The AccountTypeProductEligibilityImplementationAccountTypeProductEligibilityImplementation looks up the Opportunity, Order, or Quote object account SLA and record type and checks them against the Product Eligibility related list.
-
The EligibilityRulesFlowImplementationEligibilityRulesFlowImplementation runs the active eligibility rules that are in the Eligibility Rules flow.
-
The FilterEligibilityImplementationFilterEligibilityImplementation runs all active eligibility rules for the opportunity, order, or quote.
Input Parameters
item
Required
Type: sObject
Parent item that contains the account—opportunity, order, or quote
retval
Required
Type: List<PricebookEntry>
Passes the list of price book entries to evaluate for this account
Output Parameters
pricebookEntryList
Type: List<PricebookEntry>
Returns a filtered list of eligible price book entries
Sample Implementation
public with sharing class SampleEligibilityImplementation implements GlobalInterfaces.ProductEligibilityInterface
{
public List<PricebookEntry> getEligibleProducts(SObject parentItem, List<PriceBookEntry> pricebookEntryList)
{
/*
This code runs the AccountTypeProductEligibility (our original code)
It then further limits that result set based on Annual Revenue.
Account.AnnualRevenue is a std field
ProductChildItem_c.AnnualRevenue_c is a telco field that has been there since the beginning but not
exposed in the layout. The logic below excludes the product if the PCI.AnnualRevenue > Account.AnnualRevenue
*/
// run the Vloc Eligibility
string impl = 'AccountTypeProductEligibility';
Type et = Type.forName(impl);
Logger.dbg('Eligibility');
GlobalInterfaces.ProductEligibilityInterface pei = (GlobalInterfaces.ProductEligibilityInterface)et.newInstance();
pricebookEntryList = pei.getEligibleProducts(parentItem, pricebookEntryList);
// now exclude products for accounts with < specified Annual Revenue
string pricebkId = (string)parentItem.get('Pricebook2Id');
ID recordId = (ID)parentItem.get('AccountId');
Map<ID, string> productIdMap = new Map<ID, string>();
for(PriceBookEntry pbe: pricebookEntryList)
{
productIdMap.put(pbe.Product2Id, 'ProductId');
}
Schema.SObjectType objType = parentItem.getSObjectType();
string objName = objType.getDescribe().getName();
Account acct = [SELECT
ID,
AnnualRevenue
FROM
Account
WHERE
ID = : recordId
LIMIT 1];
double annRevenue = acct.AnnualRevenue;
List<ProductEligibility_c> ruleList = [SELECT
ID,
AnnualRevenuec,
Product2Idc
FROM
ProductEligibility_c
WHERE
Product2Id_c in: productIdMap.keySet() AND AnnualRevenue_c != null];
for(ProductEligibility__c pet: ruleList)
{
if(pet.AnnualRevenue__c > annRevenue)
{
productIdMap.remove(pet.Product2Id__c);
Logger.dbg('removing product Id ' + pet.Product2Id__c);
}
}
if(productIdMap != null)
{
pricebookEntryList = [SELECT
Id,
Pricebook2Id,
Product2Id,
Product2.Type_c,
Product2.SubTypec,
ProductCode,
Product2.Description,
Product2.Name,
UnitPrice,
Name,
Product2.JSONAttributec,
RecurringPrice_c,
IsActive
FROM
PricebookEntry
WHERE
Pricebook2Id = : pricebkId AND IsActive = true AND Product2Id in: productIdMap.keySet()
ORDER BY
Product2.Name];
}
system.debug(':::Executed Sample Eligibility Implementation');
return pricebookEntryList;
}
}
