cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement FacetSearchListener to add dynamic Solr filters ?

Former Member
0 Kudos
683

I am working on a project where I need to apply dynamic filter in the implementation of FacetSearchListener, before Solr query is executed, based on the request. How will I be able to distinguish the request in the listener class so that if else condition can be applied.

tylermac
Product and Topic Expert
Product and Topic Expert
0 Kudos

could you provide more details on when the filter should apply vs not apply? it will help with a solution. also, what version of hybris is this for?

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member537989
Contributor
0 Kudos

if you don't own the code which creates SolrSearchRequest/SearchQuery, etc and you dont want to override the existing services like de.hybris.platform.commerceservices.search.solrfacetsearch.impl.DefaultSolrProductSearchService then simplest way will be to call seach API inside SessionService.executeInLocalView method and pass your parameter(s) to a custom FacetSearchListener as part of session context. Then your FacetSearchListener can obtain sessionService.getAttribute() and do related logic.