Calls to the Product Recommendation API deliver Einstein recommendations. The API is accessed using a wire adapter to provide data to a Lightning web component. In this case, the Product Recommendation API returns a set of products to populate the Einstein Recommendations component.
ProductRecommendationsAdapter Wire Adapter
The ProductRecommendationsAdapter returns Einstein product recommendations. Implement this wire adapter by importing it from the einsteinAPI module within the commerce namespace (commerce/einsteinAPI) and then declaring its required parameters with the @wire decorator.
Parameters
Recommender Name—The name of the recommender. This parameter determines what kind of product results you see. It must be one of the recommender names listed in the Recommender Names and Anchors table.
Anchor Type—The anchor type is either PRODUCT, CATEGORY, or NO_CONTEXT. A product recommendation with an anchor type PRODUCT bases its results on the product IDs that you pass.
Anchor Value—If the anchor type is PRODUCT, the value is a list of 18-character product IDs. If the anchor type is CATEGORY, the value is a list of 18-character category IDs. If the anchor type is NO_CONTEXT, there’s no anchor value; it can be null or undefined.
Result
products—A list of product details.
recoUUID—A string representing the unique ID for the recommendation response. Use this value when you trigger the viewReco and clickReco activities.
Constants
ANCHOR_TYPE.PRODUCT
ANCHOR_TYPE.CATEGORY
ANCHOR_TYPE.NO_CONTEXT
Recommender Names and Anchors
Each recommender name requires a specific anchor type and anchor value. For example, if you use the recommender name “similar-products,” the anchor type must be PRODUCT, and the anchor value must be a list of product IDs. This table shows the anchor type and value associated with each recommender name.
Anchor Type
Anchor Value
Recommender Names
NO_CONTEXT
Any value that evaluates to false. For example: null or undefined.
personalized-for-shopper
recently-viewed
top-selling
PRODUCT
A list of one or more 18-character product IDs. For example: ['01t000000000000001', '01t000000000000002', '01t000000000000003'].
complementary-products
customers-who-bought-also-bought
recently-viewed
similar-products
upsell
CATEGORY
A list of one or more 18-character category IDs. For example: ['0ZG000000000000001', '0ZG000000000000002', '0ZG000000000000003'].