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
7 comments
Hi,
Thanks for sharing this.
I am able to successfully filter the records using this logic, but the dimension value count is not reflected correctly. Means, the RefinementMenu section of the assembler response is not filtered based on the above code. How can I correct that ?
Records are filtered with the given filter. But the dimension values are not in sync with the records in the results.
Hi Sony,
Thanks for referring this. Spotlight handler navigation state is generally different than refinement menu handler and spotlight is meant for only display products. If you want this to be achieved across all handlers better to change in navigation state builder so that same filter would be passed to all handlers.
Let me know incase any issues.
Thanks,
Ajay Agrawal
Thank you Ajay for the quick response.
You mean, I need to invoke the NavigationState.updateFilterState(FilterState paramFilterState) ?
Hi Sony,
Extend NavigationStateProcessor class and override process method. here is method signature
public void process(NavigationState pNavigationState)
first get all record filters from navigation state object and set it back using code like below :-
pNavigationState.getFilterState().setRecordFilters(<>);
This will pass same record filter across all handlers.
I hope this helps.
Thanks
Thank you Ajay. I will try this.
How to create own Refinement sort order in Hanlder in Endeca
Endeca out of the box provide only alphabetical and dynamic ranking sort order and that needs to be used. Can you please provide the use case for defining own sort order?
Post a Comment
Note: Only a member of this blog may post a comment.