A
result filter modifies the logical object (noun) before the search
result is returned to the storefront. The filter has full access to
the CatalogNavigationView
noun. Therefore, more data
can be inserted, updated, or removed from any parts of the noun and
its noun parts, such as CatalogEntryView or CatalogGroupView. Each
result filter can be separately registered to any search profile result
section so that it can be reused for other search operations.
Note: Result filters must not contain
any search engine-specific code.
Procedure
- Create a class that:
- Extends from the com.ibm.commerce.catalog.facade.server.services.search.metadata.AbstractSearchResultFilterclass,
and
- Implements the com.ibm.commerce.foundation.server.services.search.metadata.SearchResultFilter interface.
- Implement the
filter
method which takes
the SelectionCriteria
object and the DataObject
as
input parameters. The SelectionCriteria
object is
a Java representation of the original search expression, where each
search criteria is stored as a control parameter object. The DataObject
is
the logical object (noun) that represents the search result and is
used by the storefront.Note: You must first call the following
method to initialize its abstract class:
super.filter(selectionCriteria, dataObject);
It can be retrieved by typecasting into the
CatalogNavigationViewType
:
CatalogNavigationViewType catalogNavigationView = (CatalogNavigationViewType) dataObject;
- Helper methods are available from
its abstract class which can be used for retrieving from the control
parameters:
Example
The following download contains a code sample for creating
a custom result filter: