Showing results for 
Search instead for 
Did you mean: 

Adding new solr sort with custom logic to sort

0 Kudos

Dear Export,

I want to add a new solr sort name - "Customer Price Asc and Customer Price Dsc" on Product Listing Page and Search. We already have OOTB box sort like, Name Asc, Name Dsc, Price Asc and Price Dsc in sort drop down, but want this another sort on newly added attribute called "Customer Price".

On slor data is indexed in below form.


I followed the steps mentioned on below link in sap help and creaed provider - customPriceAttributeSortProvider

<bean id="customPriceAttributeSortProvider"


<property name="comparator" ref="customPriceFacetAttributeComparator"/>


<bean id="customPriceFacetAttributeComparator"


<property name="comparator" ref="customPriceAttributeComparator"/>


<bean id="customPriceAttributeComparator"



Below is the impexes for customer price attribute and solr sort

INSERT_UPDATE SolrIndexedProperty ;solrIndexedType(identifier)[unique=true];name[unique=true];type(code);customFacetSortProvider;facetSort(code)

;$solrIndexedType;customerPrices ;string;customPriceAttributeSortProvider ;Custom

# Define the available sorts

INSERT_UPDATE SolrSort;&sortRefID;indexedType(identifier)[unique=true];code[unique=true];useBoost



# Define the sort fields

INSERT_UPDATE SolrSortField;sort(indexedType(identifier),code)[unique=true];fieldName[unique=true];ascending[unique=true]



After running the above impex i can see the new sort field added in drop down but its not returning the expected result, also when i put the debug

point to class - CustomPriceAttributeComparator and could not see the call to this class and the time of indexing or when we choose the customer price sort using drop down.

Any help will be appreciated,

Thanks in advance

Kundan Kumar

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Did you find a solution?, I have the same problem.