You are here:
Recommend Visits for Specific Stores
Use Apex to select a list of stores that you want Einstein to provide visit recommendations for. After you create an Apex action, use the Generate element in your strategy to select the Apex action.

Use more general search terms.
Select fewer filters to broaden your search.
Use Apex to select a list of stores that you want Einstein to provide visit recommendations for. After you create an Apex action, use the Generate element in your strategy to select the Apex action.
| Available in: Professional, Enterprise, and Unlimited editions where Consumer Goods Cloud is enabled. |
Here's what an Apex class for filtering stores looks like:
global class LoadStores {
global class RecommendationRequest {
@InvocableVariable(label='Store Ids')
public String siteIds;
}
@InvocableMethod(label='Get Stores from Request' description='Gets stores that are chosen in the request')
public static List<List<Recommendation>> getVisits(List<RecommendationRequest> requests) {
List<List<Recommendation>> recos = new List<List<Recommendation>>();
for(RecommendationRequest request : requests){
List<Recommendation> output = new List<Recommendation>();
List<String> siteList = request.siteIds.split(',');
List<RetailStore> stores = [SELECT Id, Name FROM RetailStore WHERE Id IN :siteList];
for(RetailStore store : stores){
Recommendation rec = new Recommendation(
Name = store.Name,
Description = store.Name,
ExternalId = store.Id
);
output.add(rec);
}
recos.add(output);
}
return recos;
}
}
After you specify the Apex action in the strategy, specify the invocable variable label as the parameter for the Apex action. In the Map element of your strategy, map the parameter with the Id of the stores you want visit recommendations for. The store IDs must be specified inside double quotes in a comma-separated list.

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.