solrsap-commerce-cloudimpex

How to add Hybris Solr By for Boolean value


I have a Solr indexed property called isNewProduct (boolean) and I want to create a new Solr By option for this attribute. (the products with isNewProduct==true must appear first).

Any hint about how can I achieve this ?


Solution

  • All you have to do is run below Impex (change it with your actual values) and you are done.

        $lang=en
        $solrIndexedType=YourProductType
    
    
        INSERT_UPDATE SolrSort ; indexedType(identifier)[unique=true] ; code[unique=true] ; name[lang=$lang] ; useBoost
                               ; $solrIndexedType                     ; isNewProduct      ; New Product      ;false 
    
        INSERT_UPDATE SolrSortField ; sort(indexedType(identifier),code)[unique=true] ; fieldName[unique=true] ; ascending[unique=true]
                                    ; $solrIndexedType:isNewProduct                   ; isNewProduct           ; true 
    

    Please note, when we add a new SolrSort, Hybris internally added its reference to SolrIndexedType in sorts field so that you can see that option on the storefront. But if your SolrSort value is missing, you can always verify and correct it using back-office/Impex.

    Something like below

    INSERT_UPDATE SolrIndexedType ; identifier[unique=true] ; sorts(code)                                    
                                  ; $solrIndexedType        ; SolrSortCode1,SolrSortCode2,isNewProduct