In Hybris how to add or update OOTB Sort by Options?


If you want to add or update existing Sort Option from the category or product listing page then you can just remove/update that value from sort list of SolrIndexedType (using hmc/backoffice/impex). In this post, you can see what are all related ItemTypes for SortBy options changes.

Define SolrIndexedProperty

INSERT_UPDATE SolrIndexedProperty ; solrIndexedType(identifier)[unique=true] ; name[unique=true]      ; type(code) ; sortableType(code) ; currency[default=false] ; localized[default=false] ; multiValue[default=false] ; useForSpellchecking[default=false] ; useForAutocomplete[default=false] ; fieldValueProvider                      ; ftsPhraseQuery[default=false] ; ftsPhraseQueryBoost ; ftsQuery[default=false] ; ftsQueryBoost ; ftsFuzzyQuery[default=false] ; ftsFuzzyQueryBoost ; ftsWildcardQuery[default=false] ; ftsWildcardQueryType(code)[default=POSTFIX] ; ftsWildcardQueryBoost ; ftsWildcardQueryMinTermLength
                                  ; $solrIndexedType                         ; name                   ; text       ; sortabletext       ;                         ; true                     ;                           ; true                               ; true                              ;                                         ; true                          ; 100                 ; true                    ; 50            ; true                         ; 25                 ;                                 ;                                             ;                       ;
                                  ; $solrIndexedType                         ; priceValue             ; double     ;                    ; true                    ;                          ;                           ;                                    ;                                   ; productPriceValueProvider               ;                               ;                     ;                         ;               ;                              ;                    ;                                 ;                                             ;                       ;                              

Define the available sorts

INSERT_UPDATE SolrSort ; &sortRefID ; indexedType(identifier)[unique=true] ; code[unique=true] ; useBoost  
                       ; sortRef3   ; $solrIndexedType                     ; name-asc          ; false   
                       ; sortRef4   ; $solrIndexedType                     ; name-desc         ; false   
                       ; sortRef5   ; $solrIndexedType                     ; price-asc         ; false   
                       ; sortRef6   ; $solrIndexedType                     ; price-desc        ; false   

Define the sort fields

INSERT_UPDATE SolrSortField ; sort(indexedType(identifier),code)[unique=true] ; fieldName[unique=true] ; ascending[unique=true]                
                            ; $solrIndexedType:name-asc                       ; name                   ; true                  
                            ; $solrIndexedType:name-desc                      ; name                   ; false                 
                            ; $solrIndexedType:price-asc                      ; priceValue             ; true                  
                            ; $solrIndexedType:price-desc                     ; priceValue             ; false                 

Update sorts option in Indexed type Product

INSERT_UPDATE SolrIndexedType ; identifier[unique=true] ; type(code) ; variant ; sorts(&sortRefID)                                    
                              ; $solrIndexedType        ; Product    ; false   ; sortRef3,sortRef4,sortRef5,sortRef6

Do you know how to add custom Sort By Option with custom AttributeComparator?



Author Image

Ankitkumar Patel

Sr. SAP Hybris consultant, having 6+ years experience in Hybris, Java, J2EE. Extensive hands-on experience in SAP Hybris development, third-party integrations with Hybris, project architecture and design... Read more

Comments

Popular posts from this blog

Hybris flexible search query examples

How to remove or update all data records in Hybris?

Hybris backoffice customization