You can use the Salesforce B2C Commerce API to search for all products that are
eligible for a promotion, whether they are qualifying or discounted. You can search for
qualifying products only, discounted products only, or both.
The input parameter, PromotionProductType, used in the Search pipelet and the
ProductSearchModel scripting class, enables you to perform this level of search.
- Valid values for the B2C Commerce Script API parameter are: all,
bonus, discounted, parameter, and
qualifying.
- Valid values for the pipelet parameter are all,
qualifying, and discounted.
Note: For the Search pipelet, the same product can be returned by all
three types of search. This behavior is different than the API methods
PromotionPlan.getProductPromotionsForQualifyingProduct(Product) and
getProductPromotionsForDiscountedProduct(Product), which never
return the same promotion for a given product.
The products returned by this type of product search depend on the
class of the promotion and other aspects of its configuration. The rules
are listed below.
All Promotion Types
For all promotion types, the promotion must be marked as
searchable if you want to search for products using that promotion.
A product isn't returned by a product search if it's globally excluded,
and the individual promotion doesn't disable global product
exclusions.
There are additional rules, as follows, by promotion class:
Product Promotions
For product promotions, a search for qualifying or discounted products
returns a product if that product satisfies the qualifying or discounted
product rule, respectively.
Order Promotions
For order promotions:
- A product isn't returned by a search if it satisfies the order
promotion excluded products rule.
- If the promotion has an explicit qualifying product rule (for
example, only products in a specific category qualify), a product must
satisfy the rule in order to be returned by a qualifying product
search.
- If the promotion doesn't have an explicit qualifying product rule,
all products are returned by a qualifying product search.
- If the order promotion is configured so that discounted products is
equal to qualifying products, a discounted product
search will return the same products as a qualifying product search.
Otherwise, all products participating in the discount are returned
by a discounted product search.
Shipping Promotions
For shipping promotions:
- If the promotion has an explicit qualifying product rule (for
example, only products in a specific category qualify), a product must
satisfy the rule in order to be returned by a qualifying product
search.
- If the promotion doesn't have an explicit qualifying product rule,
all products are returned by a qualifying product search.
- No products are returned by a discounted product search because this
makes no sense for shipping promotions.
Important: You must rebuild the product index for this feature
to take effect. Because only promotions marked as searchable are
included, if you don't want the behavior to occur, you should explicitly
mark all shipping and order promotions as not searchable. In
general, if you don't use this feature in the storefront, it's better to
mark promotions as not searchable, because setting them to
searchable will increases indexing time.