cancel
Showing results for 
Search instead for 
Did you mean: 

Adding new solr sort with custom logic to sort

kundan1986
Explorer
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.

"customerPrices_eur_string_mv":["1294415:45.0"]

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

https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/1905/en-US/8ba153f886691014925f989160e5...

<bean id="customPriceAttributeSortProvider"

class="de.hybris.platform.solrfacetsearch.config.impl.DefaultFacetSortProvider">

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

</bean>

<bean id="customPriceFacetAttributeComparator"

class="de.hybris.platform.acceleratorservices.search.comparators.FacetValueNameComparator">

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

</bean>

<bean id="customPriceAttributeComparator"

class="com.gardena.core.search.comparator.CustomPriceAttributeComparator">

</bean>

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

;sortRef5;$solrIndexedType;customerPrices-asc;false

;sortRef6;$solrIndexedType;customerPrices-desc;fal

# Define the sort fields

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

;$solrIndexedType:customerPrices-asc;customerPrices;true

;$solrIndexedType:customerPrices-desc;customerPrices;false

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.