Duplicates filter

Description

The duplicates filter is a module that prevents the same recommendations from being displayed multiple times on a page. It works by storing the identifiers (ItemId) of already shown products and excluding them from new recommendation sets.

This is a crucial tool for enhancing user experience by maintaining content diversity across different recommendation blocks on the page.

🚧

Note

The duplicates filter module is not used in all blocks. Its presence depends on the configuration of the specific block and scenario. Therefore, removing the filter is not always necessary.

Why is the duplicates filter important?

The duplicates filter addresses several key objectives:

  • Uniqueness of recommendations:
    If a page has multiple blocks, such as "Similar Products" and "Frequently Bought Together", the filter ensures that the same products do not appear in each block. This makes recommendations more engaging and useful for the user.
  • Avoiding repetition:
    Repeated products in different parts of the page can annoy users, reducing the value of recommendations and the overall interface impression.
  • Optimizing perception:
    Content diversity helps retain user attention and increases the likelihood of interaction with recommendations.

How does the filter work when there are two blocks on a page?

When two or more recommendation blocks are displayed simultaneously on a page, the duplicates filter operates as follows (example):

  1. In the first block ("Similar products"), products with ItemId: 101, 102, 103 are displayed.
  2. In the second block ("Frequently bought together"), the filter excludes these products (101, 102, 103) and shows only new ones, such as 104, 105, 106.

In this case, resetting the filter is not necessary because its primary purpose is to maintain uniqueness between different blocks on the same page. Removing duplicates here benefits the user by ensuring variety. If the filter is reset using delete retailrocket.modules.duplicates;, products from the first block may appear in the second, disrupting the uniqueness logic.

Why and when to reset the duplicates filter?

However, there are situations where resetting the duplicates filter is necessary. This is related to re-rendering the same recommendation block:

  • Updating a single block:
    Suppose a user adds a product to the cart, and the "Cart recommendations" block needs to be updated. The duplicates filter may consider new recommendations as duplicates of previously shown products (based on their ItemId) and exclude them. As a result, the block may remain empty or be filled incorrectly.
  • Example: If the first render of the block shows products 101 and 102, and upon updating, 101 and 103 are suggested, the filter will exclude 101 as a duplicate, leaving the user with only 103 or nothing if no other options are available.

To solve this issue, use the command delete retailrocket.modules.duplicates;. This resets the filter by clearing the list of stored identifiers. After this, the block can display fresh content, even if some products were previously shown.

Summary

  • For multiple blocks on a page:
    The duplicates filter automatically excludes repeats between blocks, preserving diversity. There is no need to remove duplicates in this case—it is its standard function.
  • For updating a single block:
    If a block is re-rendered (e.g., when the page state changes), the filter may interfere by excluding new recommendations. Resetting the filter with delete retailrocket.modules.duplicates; allows displaying a full set of fresh recommendations, even if they partially overlap with previous ones.

Thus, the duplicates filter is a flexible tool that should be used contextually: retained for uniqueness between blocks and reset for relevance during updates.