Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Understand How Sorting Rules Work

Learning Objectives

After completing this unit, you’ll be able to:

  • Explain the Salesforce B2C Commerce inheritance model for process sorting rules.
  • State the importance of the default sorting rule.
  • Explain how B2C Commerce breaks sorting rule ties.
  • List the sorting rules best practice sort order.

How Sorting Rule Work

Brandon Wilson, Cloud Kicks merchandiser, has a lot of flexibility when configuring sorting rules. He can configure one rule with a single attribute, a rule with a weighted blend of multiple attributes, and multiple rules. That’s a lot of options! 

He first learns about the foundation of sorting rule processing: the default sorting rule. The default sorting rule uses the storefront’s catalog/category structure, which governs storefront navigation. Category navigation often displays as tabs across the storefront page, showing subcategories when clicked, and in a left navigation pane. While navigation is about the category structure, keyword search is when a shopper enters text into the search field. The shopper is searching for what they want to buy.

Brandon wants to include attributes in his default sorting rule to accommodate both category navigation and keyword search. For example, he uses the category position and search placement attributes in his default sorting rule. He creates other sorting rules that take priority over these for more personalized search results.

The default sorting rules return products based on the search index document order, that is, the order in which the products are stored in the search index. You can’t control the index document order, and it can change from one index build to another. That’s why it’s important that Brandon gets more creative with his rules.

Sorting Rule Inheritance

B2C Commerce uses an inheritance model based on the storefront’s catalog/category data structure to process sorting rules. The default sorting rule that Brandon configures at the catalog root level is inherited by all subcategories. This gives him global coverage and a baseline strategy that he can vary by product type, campaign, or season. He can determine strategies for each category and provide a more specific product sort by overriding the default rule on an individual subcategory level. Here’s the structure.

  • Default
  • Category tree
  • Override at category or subcategory with a different rule

Remember, a search sorting rule is separate from category sorting, just as a keyword search is different from category navigation. To get started, Brandon creates a map of his site’s category structure, and then determines the strategy he wants to use for each category. For his running shoes category, for example, he wants to give the newest and hottest products high-visibility positions on the page. For his clearance category, he wants to give premium placement to high-inventory products.

Map of the Cloud Kicks catalog structure, with top categories: Mens, Women, Kids, New Arrivals, and Sales. Sub-categories include Shoes, Apparel, Tops, Boys Shoes, and Girls Shoes.

Rule Order and Breaking Ties

During a search results sort, B2C Commerce evaluates products by the value in the top attribute in the sorting rule list. This usually means the category structure. It breaks ties in the values of the first attribute using the second attribute, then breaks ties in the values of the first and second attributes using the values of the third attribute. This continues for all attributes used in sorting.

After B2C Commerce evaluates all the sorting rules, it sorts products that match (tie) exactly on all attributes, or have null values for the attributes, via the default sorting rules. These rules return products based on the order in which the products are stored in the search index. 

Brandon wants to test with an example, so he creates three sorting rules to sort five products.

  1. product.searchPlacement: Sort products by search placement and specify products that you want to appear first. Sort by the product name attribute in ascending order.
  2. activeData.returnRate: Sort by lowest return rate (active data attribute) in ascending order.
  3. activeData.salesVelocityWeek: Sort by highest sales velocity (active data attribute) in descending order.

He tests these products in the Running Shoe category.

  • Flow Flyknit
  • Smooth Trail 3
  • Air Flow Stride
  • Air Float Max
  • Cheetah Ride 4

Here’s how B2C Commerce sorts these products.

  1. B2C Commerce applies the product.searchPlacementrule, which sorts based on the catalog structure in ascending order.
    • Products are divided in half.
    • Items with equal value appear in any order, resulting in this placement.

      Product Sort Order
      Air Float Max 1
      Cheetah Ride 4 1
      Air Flow Stride 1
      Flow Flyknit 2
      Smooth Trail 3 2
      Happy Trail 2
  2. B2C Commerce determines the order of items with identical values and places them in ascending order, starting with the first (1) placement.
    • Air Flow Stride and Cheetah Ride 4 switch places.
    • Smooth Trail 3 and Happy Trail switch places.

      Product Sort Order
      Air Float Max 1
      Air Flow Stride 2
      Cheetah Ride 4 3
      Flow Flyknit 4
      Happy Trail 5
      Smooth Trail 3 6
  3. B2C Commerce applies the activeData.returnRaterule to sort by lowest return rate (active data attribute) in ascending order.
    • Happy Trail has the lowest return rate, followed by Flow Flyknit.
    • The others have the same return rate.

      Product Sort Order
      Happy Trail 1
      Flow Flyknit 2
      Air Float Max 3
      Air Flow Stride 4
      Cheetah Ride 4 5
      Smooth Trail 3 6
  4. B2C Commerce applies the activeData.salesVelocityWeek rule to sort by highest sales velocity(active data attribute) in descending order.
    • Cheetah Ride 4 has the lowest sales velocity, followed by Smooth Trail 3.
    • The others have the same sales velocity.

      Product Sort Order
      Cheetah Ride 4 1
      Smooth Trail 3 2
      Happy Trail 3
      Flow Flyknit 4
      Air Float Max 5
      Air Flow Stride 6

Brandon pays close attention to rule order because changing it can change the placement, which affects the shopper experience. Here's what happens if he changes the order of the last two rules.

  1. Cheetah Ride 4 has the lowest sales velocity, followed by Smooth Trail 3, so they move to the top of the list.
  2. Happy Trail has the lowest return rate, followed by Flow Flyknit, resulting in this placement.

    Product Sort Order
    Happy Trail 1
    Flow Flyknit 2
    Cheetah Ride 4 3
    Smooth Trail 3 4
    Air Float Max 5
    Air Flow Stride 6

Brandon can take the guesswork out of which sort order to use by running an A/B test with both rules. He can also combine the two attributes into one rule and give them a 50/50 weighting.

Sort Order Best Practice

Brandon uses this best practice search results sort order when he creates his sorting rules. B2C Commerce gives each type of rule priority over the rules that follow.

  1. Explicit category placement: Assign a position for a product in the results returned for a category. Use this when a shopper is navigating to a page and not for keyword searches.
  2. Explicit product placement: Assign the search placement attribute for a product to the values 1-8 (NLA - Top Featured).
  3. Explicit search rank: Assign low, medium, or high in the product search rank attribute.
  4. Availability ranking: The availability of an item influences its position in the search results, so that out-of-stock items appear at the end of the search results.
  5. Text relevance: You can boost the importance of certain attributes, so that if a search term is found in that attribute, it's treated as more significant than other fields. For example, if you boost product name, then if the term is found in the product name it's treated as more important than if the term is found in a long description. This only works in a search-specific sorting rule.
  6. Term frequency: If all sorting is removed and no sorting rules are configured, results are returned based on the frequency of the search term in the indexed fields of the document. This is for when content is included in the search results.

Brandon uses the Show Orderable Products Only setting to completely remove unavailable products from search results. He can remove individual unavailable products from the search results as well.

Here’s a typical default sorting rule in Business Manager, called best-matches. It looks just like the best practice list, without availability ranking and term frequency.

The default sorting rule, called best-matches, uses static sortings (category position, search placement, and rank), text relevance, and then explicit sortings.

Next Steps

In this unit, you learned the importance of the default sorting rule and sorting rules best practice sort order. You explored how B2C Commerce uses inheritance as it processes sorting rules and how it breaks sorting rule ties. Next, you learn how to create B2C Commerce sorting rules in Business Manager.

Resources

Comparta sus comentarios sobre Trailhead en la Ayuda de Salesforce.

Nos encantaría conocer su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios cuando quiera desde el sitio de la Ayuda de Salesforce.

Más información Continuar para compartir comentarios