Facets behavior extensions in Oracle ATG Web Commerce Endeca
Recently, I was tasked with a challenging assignment on one of our Oracle e-commerce platform projects was the client of ours decided to opt out of OOTB Endeca’s RefinementMenu cartridge and asked us to make it work slightly different from its original version. I will first describe how Endeca’s RefinementMenu cartridge works and then explain how I made it work in accordance with client’s needs.
Imagine we go to a product listing page on an online book shop and see a faceted navigation panel with facets like an author, genre, and language on the left-hand side, one-way it can be applied by a standard OOTB Endeca cartridge known as RefinementMenu for every facet (using Endeca’s terminology: dimension). The RefinementMenuHandler prepares RefinementMdexQuery, which executes a mdex request and finally retrieves results that are then parsed to obtain actual refinement objects that filled faceted navigation panel for an appropriate facet wherein Experience Manager, we specify a set of facets we want to see on a sidebar using RefinementMenu cartridge. Suppose we have this following this panel with multi-select refinements:
Let’s see how it changes after we apply some refinement. We use OOTB RefinementMenuHandler to fill guided navigation panel.
After selecting J.-P. Desmoulins, who writes only in French in genres of travel and history, “language” facet becomes hidden, and “genre” facet does no longer include “religion” and “science” refinements. This occurs as a result of Endeca’s inability to return results on mdex request when choosing J.-P. Desmoulins and “science” genre, for instance. As this author writes only in French, the system does not offer any refinement for language so, this behavior excludes combo of refinements that produce no result, but what if the client does not want these facets and refinements to be hidden, but wants to save all possible filtering criteria from the beginning when the user got to the listing page.
Please see the following table:
The client also wants the system to display a message if a set of refinements returns zero results that read as follows: “No results found. Please try to adjust filtering criteria.”
The solution we found to meet the client’s need was to use an ATG session scoped component and make a specific map structure to save this facet data during the user navigation process. We named this map structure guidedNavigationSnapshots.
As a key in this map stands a combination of navigation filters, search filters, and user segments. These both filters are retrieved from UrlNavigationState object. Both filters correspond to a given state of a guided navigation panel. User segments divide various types of listing pages. Guided navigation panels are identified by a value in this map, where every value has a List type so, when a user goes on the listing page for the first time, a special droplet is invoked in order to insert a guided navigation panel snapshot to guidedNavigationSnapshots map.
Let’s suppose there is a website that sells books and magazines the user goes on a listing page for the first time, search filters and user segments are empty, but navigation filters hold a filter for the option “Category: Books”, after, the user applies some refinement (for example by the author J-P. Desmoulins), navigation filters change to the following: “books_dimval_id+Desmoulins_dimval_id”. We want to obtain the original navigation panel before the author J-P. Desmoulins was selected. In order to obtain it from the map, we have to form the suitable key of the guidedNavigationSnapshots map because navigation filters array is filled by the NavigationStateBuilder in the order of refinement selection, we need to remove the last filter from the array and create a key from these filters and segments. Using this key, we obtain the guided navigation panel that we need the only remaining thing to do is to populate the refinement links on the retrieved navigation panel using the NavigationState object for the current request. The RefinementBuilder can help solve this issue.
After that, the user can select Travel refinement from the genre facet to get the proper panel the last navigation filter needs to be removed and a snapshot key by these filters needs to be formed. Then we must check if guidedNavigationSnapshots contains this key. If so, we will retrieve the value for the key; if not, we will remove the last navigation filter again until the end of the array. If no data is retrieved from the map, then-current guided navigation panel should be added to the guidedNavigationSnapshots map.
Let’s suppose we have the following case. The user selects religion refinement and sees, “No results found. Please try to adjust the filtering criteria” message. Then he can remove this refinement and see the results. After that, if the user goes on the listing page under Magazines category, he will only see facets related to magazines and not books, because the guidedNavigationSnapshots map will not contain the key for the option “Category: Magazines”.
To sum up, this is only one possible solution that we thought was effective and suitable for the client. Although we deviated from Endeca’s OOTB refinement functionality, we offered our custom solution that works in accordance with the client’s specific requirement of keeping all the original facets in the guided navigation panel.