Exclude Unavailable Products from Search Results

The Salesforce B2C Commerce Search module enables you to exclude unavailable products from search results in the storefront at the site level and at the product level. This is to avoid frustrating customers by showing them products they can't purchase.

The site-level feature, describe here, is only useful for sites that use an inventory list to control availability. The deprecated in-stock product attribute doesn't control the availability.

A product is considered available if one of the following is true:

  • It has an inventory record with an ATS > 0, or
  • It has no inventory record but the default-in-stock flag of the site inventory list is true.

Inventory records for base products have no effect on whether or not they appear in search results because the availability of such products is determined by the availability of their variation products. The same is true for product-sets. Bundled products are available if one of the following is true:

  • It has an inventory record with an ATS > 0.
  • It has no inventory record, and the ATS (which is calculated based on the availability of the bundled products) > 0.

To remove unavailable products from searches:

  1. Select Search > Search Preferences.
  2. Check the option Show Orderable Products Only.
  3. Navigate to Search > Search Indexes and rebuild the product index.
Note: If the search preferences Show Orderable Products Only option is enabled, unavailable products don't appear during storefront keyword searches and browsing operations, but unavailable products are still reachable by direct link.

If a merchant requires the flexibility to show or hide unavailable products per query, the Business Manager Show Orderable Products Only option might be overridden programmatically. The Search pipelet offers an optional input parameter, OrderableProductsOnly, which can be used to specify the desired behavior. The class dw.catalog.ProductSearchModel, has a similar property.