Endeca Cartridge Handler : How to Add dynamic Record Filter in RecordSpotlightHandler?
The Record Spotlight cartridge handler can promote either specific records or a set of dynamic records based on a navigation state.
Behaviour : -
RecordSpotlightHandler provides functionality to add any static record filter OOTBs and can be setup using recordFilterBuilders properties. What if some dynamic record filters need to be applied to get featured record or recommendation.
Example : Show 10 featured product excluding the current brand selection by the user.
Solution :-
Extend RecordSpotlightHandler that implements dynamic filtering based on previous request or profile.
Find out the code below to extend
Find out sample configurable cartridge templates screenshot
Click here to see more post related to Endeca Cartridge Handlers
From Author
Was this post resolve the solution you are looking for? what do you think about this solution?
Provide your comments
Behaviour : -
RecordSpotlightHandler provides functionality to add any static record filter OOTBs and can be setup using recordFilterBuilders properties. What if some dynamic record filters need to be applied to get featured record or recommendation.
Example : Show 10 featured product excluding the current brand selection by the user.
Solution :-
Extend RecordSpotlightHandler that implements dynamic filtering based on previous request or profile.
Find out the code below to extend
| package com.company.endeca.assembler.cartridge.handler; import java.util.ArrayList; import atg.core.util.StringUtils; import atg.endeca.assembler.navigation.filter.FilterUtils; import atg.endeca.assembler.navigation.filter.PropertyConstraint; import atg.servlet.DynamoHttpServletRequest; import atg.servlet.ServletUtil; import com.endeca.infront.assembler.CartridgeHandlerException; import com.endeca.infront.cartridge.RecordSpotlight; import com.endeca.infront.cartridge.RecordSpotlightConfig; import com.endeca.infront.cartridge.RecordSpotlightHandler; import com.endeca.infront.cartridge.RecordSpotlightSelection; public class RecommendationHandler extends RecordSpotlightHandler { . . . public void preprocess(RecordSpotlightConfig cartridgeConfig) throws CartridgeHandlerException { FilterState filterState = cartridgeConfig.getRecordSelection().getFilterState(); if (filterState != null) { // Update the record filter list with RecordFilters generated by the RecordFilterBuilders. List<String> filtersList = filterState.getRecordFilters(); filtersList.addAll(getExcludingList(filtersList)); selection.getFilterState().setRecordFilters(filtersList); } super.preprocess(cartridgeConfig); } private void getExcludingList(List<String> tobeAddedFilterList) { DynamoHttpServletRequest dynamoRequest = ServletUtil.getCurrentRequest(); List<String> excludingItems = (List<String>) dynamoRequest.getAttribute("excludingItems"); if (null != excludingItems) { for (String product : excludingItems) { tobeAddedFilterList.add(FilterUtils.not(new PropertyConstraint("product.repositoryId", product))); }} } . . . } |
Find out sample configurable cartridge templates screenshot
Click here to see more post related to Endeca Cartridge Handlers
From Author
Was this post resolve the solution you are looking for? what do you think about this solution?
Provide your comments

Discussion (7)
Technical questions and architecture discussionsJoin the Discussion