Duplicate filter
Description
The duplicate filter is a module that prevents the repeated display of the same recommendations on a page. It works by storing the IDs (ItemId) of already shown products and excluding them from new sets of recommendations.
This is an important tool for improving user experience, as it helps maintain content diversity across various recommendation blocks on the page.
The duplicate filter module is not used in all blocks. Its presence depends on the configuration of a specific block and scenario. Therefore, removing the filter is not relevant in all cases.
Why is a duplicate filter needed?
The duplicate filter solves several key tasks:
- Uniqueness of recommendations: If there are several blocks on the page, for example, "Similar products" and "Frequently bought together", the filter ensures that the same products are not displayed in each of them. This makes recommendations more interesting and useful for the user.
- Avoiding repetitions: Repeated products in different parts of the page can annoy the user, reducing the value of recommendations and the overall impression of the interface.
- Optimization of perception: Content diversity helps to retain user attention and increases the likelihood of interaction with recommendations.
How does the filter work when there are two blocks on the page?
When two or more recommendation blocks are displayed simultaneously on a page, the duplicate filter works as follows (example):
- The first block ("Similar products") displays products with ItemId: 101, 102, 103.
- In the second block ("Frequently bought together"), the filter excludes these same products (101, 102, 103) and shows only new ones, for example, 104, 105, 106.
In this case, there is no need to reset the filter, because its main goal is to maintain uniqueness between different blocks on the same page. Removing duplicates here works in favor of the user, ensuring a variety of offers. If the filter is reset using the command delete retailrocket.modules.duplicates;, then products from the first block may appear in the second block, which will violate the logic of uniqueness.
Why and when to reset the duplicate filter?
However, there are situations when the duplicate filter needs to be reset. This is related to re-rendering the same recommendation block:
- Updating a single block: Suppose the user added an item to the cart, and the "Recommendations for the cart" block needs to be updated. The duplicate filter may consider new recommendations as duplicates of previously shown products (by 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 items 101 and 102, and during the update, 101 and 103 are offered, the filter will exclude 101 as a duplicate, and the user will see only 103 or nothing if there are no other options.
To solve this problem, the command delete retailrocket.modules.duplicates; is used. It resets the filter, clearing the list of saved identifiers. After this, the block can show fresh content, even if some products have already been displayed earlier.
Conclusion
- For multiple blocks on a page: The duplicate filter automatically excludes repetitions between blocks, maintaining diversity. There is no need to remove duplicates in this case — this is its normal operation.
- For updating a single block:
If a block is re-rendered (for example, when the page state changes), the filter may interfere by excluding new recommendations. Resetting the filter via
delete retailrocket.modules.duplicates;allows showing a full set of fresh recommendations, even if they partially coincide with previous ones.
Thus, the duplicate filter is a flexible tool that should be used taking into account the context: save for uniqueness between blocks and reset for relevance during updates.