Appearance
Filter Out of Stock Products
This page describes how to set up a merchandising rule to filter out products from search and recommendation results when an associated datakey value tells us that the product is out of stock.
The purpose of this is to ensure that you do not suggest products to your users that they cannot actually purchase. This rule can be adjusted to affected your search results, your recommendations, or both, as needed.
To set this up, you will need the following set up ahead of time:
- A datakey on your products that contains a true/false Boolean e.g.
IsInStock
, OR - A datakey on your products that contains a numeric value e.g.
stockCount
To check whether this data is available on your products, confer with the products available on the Entities page.
Setting up an Out of Stock rule
To create this rule, navigate to the Merchandising -> Rules area of MyRelewise. From here, click Create new rule, and select Rule Type: Filter Rule.
Affected Context
From here, select your affected context. If you wish to affect all requests sent to Relewise, simply leave the Affected Context blank - no selection automatically includes all search- and recommendation types.
Alternatively, check off the type(s) of search or recommendations that you wish to affect. If you are unsure about the type of search or recommendation requests you are using, you can refer to the Live View pages for Search and Recommendation, and cross-reference the incoming request types against the list of available options in the Merchandising interface.
Select Entities to Filter Out
Next, identify the datakey that contains the data needed to identify a product as in stock or out of stock. This will either be a Boolean (true/false) or a Double (numeric value). The setup varies depending on the data type, as outlined below.
To find the type of data you are using, navigate to your Entities -> Products, open a product, and navigate to the datakey you wish to use. By hovering over the value of the field, you can identify its data type:
Filtering on a Boolean
To filter on a boolean, edit the Entities to Filter Out, and select Matches Product Data.
Enter (or copy-paste) the name of the datakey that stores the InStock value, and select "Add Equals Condition":
From the dropdown menu, select Boolean, and for the Data Value, select the correct value for your datakey. For instance, if your key denoted "Product is in stock", then the Boolean value for the merchandising rule should match on "False", since you want to filter out products that are not in stock. Conversely, if your key is denoted as "Product is out of stock", the merchandising rule should match on "True".
Filtering on a Double value
To filter on a Double value, edit the Entities to Filter Out, and select Matches Product Data.
Enter (or copy-paste) the name of the datakey that stores the InStock value, and select "Add Less Than Condition":
Since the content of the datakey is a numeric value, you can specify a point where the product is considered "out of stock". This may, for instance, be used in an alternative usecase to filter out or bury products that are simply in low stock, rather than completely out of stock.
For the purposes of this guide, however, we will specify that if the value of the field is less than 1
, the product should be filtered out.
Finishing Up
Regardless of the data type you use, you will be given the option to check off "Include if Key is not found" and "Must Match All Conditions". Set both of these to "True" (checked).
Once you hit "All Done", the MyRelewise interface will show you an overview of the amount of products currently affected by the rule you have created, as well as a sample list of the first 500 products that match the criteria you have set up for your rule. Use this to confirm that your products are being targeted correctly, and that your rule was set up properly.
Finally, hit "Save Rule" to save your merchandising rule.