Create Sorting Rules
Implement personalized sorting rules within your B2C Commerce storefront.
Required Editions
| Available in: B2C Commerce |
-
Go to
site
| Merchant Tools | Search | Sorting Rules.
The Sorting Rules page opens with the Sorting Rules tab open. On this tab, you create or edit your sorting rules.
-
To create a new sorting rule, click
New.
The page has three sections: Sorting Rules, Attributes, and Preview.A new sorting rule appears with the default rule ID highlighted.
-
Enter a unique rule ID and description.
You use the description to identify the rule when selecting sorting rules for categories and storefront options.
-
Choose whether you want the context of the rule to be site-specific, or globally
applied.
Selecting “global” makes the sorting rule usable in all sites.
- To add an attribute for your rule, click Add in the Attributes section.
-
Enter the attribute to sort by or select an attribute from the
list. Select the following types of attributes:
- Standard attributes: Standard attributes enable you to intervene in sorting using explicit placement of search results for categories, based on specific attributes intended for search ranking or availability.
- Product attributes: Select any single-value (non-set) attribute of the product system object to use in a sorting rule, as long as it isn’t a Password, Image, Text, HTML, or Email type of attribute. Product attributes don't require the online or searchable status for use in sorting rules.
- Active Data attributes: These attributes require the active merchandising feature to be implemented for the attribute data to be useful in sorting. These attributes include data collected from orders on your production system and information collected from storefront pages.
- Availability model attributes: These attributes require the availability, active merchandising, or both features to be implemented for the attribute data to be useful in sorting.
- Dynamic attributes: Dynamic attributes are custom combinations of attributes created by the merchant.
All system attributes are listed as
Name (type.ID). All custom attributes are listed asName (type.custom.ID). Because it's possible to have multiple attributes with the same name, check to make sure that you’re selecting the correct attribute type and ID in addition to the correct name.
Note If you create a custom enum attribute with a default value selected, the attribute isn’t set to that value for all products automatically. Therefore, sorting rules don’t take this default value into account unless you have set an explicit value for that attribute. -
In the Text Relevancy column, click in the cell for your
attribute and select whether you want to use text relevancy in
combination with the attribute, using one of the following
options:
- Yes: Use for keyword search sorting rules only. The text relevance score (from 0 through 1) is multiplied by the score of the attribute selected for the rule. This is the equivalent of a 50%-50% weighting between the selected attribute and the text relevance score. This is appropriate when there are multiple items that can have the same score from the sorting attribute, such as a recommendations sort, or when it's not readily apparent to the user that more than just the selected attribute is being used for sorting, such as a sorting for best-selling items. For example, if you have a sorting rule that sorts by a 1–5 star customer rating, selecting Yes for text relevancy is identical to selecting the Text Relevance standard attribute to directly follow the review rating attribute in the sorting rule. Because you can't use the Text Relevance standard attribute twice in the same rule and have a limited number of sorting attributes in a rule, which is useful.
- No: Use for category sorting rules only. Only the score for the attribute selected for the rule is used. This is appropriate when it's unlikely that multiple items have the same score or when the customer expects the results to be sorted only by the selected attribute.
- N/A: Displays if the selected attribute can't use text relevancy.
-
In the Direction column, click in the cell for your attribute and select the
direction of the sort. Some attributes don’t let you select direction, because it's
implied by the attribute. For example, Category Position automatically sorts items in
ascending order.
- Ascending: Sorts the results from top to bottom in the search results from the lowest value to the highest (A-Z, 1–100).
- Descending: Sorts the results from top to bottom in the search results from the highest value to the lowest (Z-A, 100-1).
- Add any additional attributes and configure them.
-
To save your rule, click Apply.
If you change a sorting rule and want to revert to the last saved value, click Cancel
- Preview the results of your new sorting rule in the Preview section.
Sort by Keyword Groups
Sorting rules can also be assigned to keyword groups, which allow you to define extra sorting rules based on customer search terms.
Required Editions
| Available in: B2C Commerce |
For example, a search containing the term "inexpensive" can cause results to be sorted from lowest to highest price regardless of the category the search is executed in.
Terms within Keyword Groups are matched in the following order:
- Full matches over partial matches.
- Exact matches over wildcard matches.
- First match from left to right in the search string.
Conflicting keyword groups apply in chronological order, from newest to oldest.
Keyword Sorting Groups are created, edited, and deleted within Search Dictionaries.
Also, keyword groups can be imported and exported using the search settings ImpEx module, and the assignments can be imported and exported using the sorting rule ImpEx module.
- To assign keyword-group-specific sorting rules, select site | Merchant Tools | Search | Sorting Rules - Keyword Search.
-
Under Search Keyword Groups, choose the correct locale and click the Search icon.
Assigned results display in the search results. Any unassigned results are in the New Assignment section dropdown.
- Under New Assignment, select an unassigned Keyword Group.
- Select a rule.
- Click Apply.
Preview Sorting Rules
Preview how sorting rules work in the storefront before using them.
Required Editions
| Available in: B2C Commerce |
- Go to site | Merchant Tools | Search | Sorting Rules.
- On the Sorting Rules page, select a sorting rule and scroll to the (sorting rule) Preview section.
- Select a category.
- Enter a search term.
-
Click Preview.
The sorted results of your search appear in the preview area.
- To clear the category and search term so that you can preview another category and search term set, click Clear.
Create Dynamic Attributes
A dynamic attribute is an attribute whose value is calculated through a formula you create, allowing you to create weighted blends of different attributes to use when sorting.
Required Editions
| Available in: B2C Commerce |
For example, to create a result set where new products and best selling products are pushed to the top, create a dynamic attribute that blends Days Available and Sales Velocity.
Because dynamic attributes are calculated, they can only be numeric, such as integer or number. Date, string, boolean, and set-of value attribute types aren’t supported. For example, if you add a new sorting rule that is Boolean in site | Merchant Tools | Search | Sorting Rules | New it isn’t selectable in site | Merchant Tools | Search | Sorting Rules | Dynamic Attributes | Add.
Sorting rules reference dynamic attributes rather than define them; therefore, when a rule containing a dynamic attribute is copied and the dynamic attribute is changed, the changes to the dynamic attribute affect both the original rule and the copy.
- Go to site | Merchant Tools | Search | Sorting Rules.
-
On the Sorting Rules page, click the Dynamic Attributes
icon in the section header.
The Dynamic Attributes window has two sections: a list of dynamic attributes and the list of attributes that, when blended, make up the dynamic attribute currently selected in the list.
-
On the Dynamic Attributes window, click New to add a new
dynamic attribute or select an attribute from the top section to edit
it.
A new attribute line appears in the top pane. If you’ve selected an existing dynamic attribute, the attributes that are blended to create the dynamic attribute value appear in the section after the list of dynamic attributes.
-
Choose whether you want the context of the attribute to be site-specific, or globally
applied.
Selecting “global” makes the attribute usable in all sites.
- Click Add to add an attribute to the currently selected dynamic attribute. A new attribute line opens in the lower pane.
-
Click in the field and then select from the list of
attributes.
The attribute list for dynamic attributes is a subset of the attribute list available for sorting rules. For example, the Standard attributes that can be used as dynamic attributes include
Text Relevance(sorting.text-relevance) andPredictive Sort(sorting.predictive-sort). -
In the Direction column, click in the cell for your
attribute and select a sorting direction.
- Ascending: Sorts the search results from the lowest value to the highest (A-Z, 1–100).
- Descending: Sorts the search results from the highest value to the lowest (Z-A, 100-1).
- In the Default Value column, click in the attribute cell and select a replacement value for stale or undefined data. For example, if you have stale data, set whether to place stale data at the top, bottom, or middle of results by default.
- Enter a percentage weight for the attribute. Make sure all weights add up to 100%.
- Click Apply.

