Hybris Solr排序 [英] Hybris Solr Sort
问题描述
我修改了代码,为价格添加了新的Solr排序.
I modified my code to add new solr sort for price.
INSERT_UPDATE FieldSolrSort;sort(indexedType(identifier),code)[unique=true];fieldName[unique=true];descending[unique=true];$IndexedType:price;priceValue;true
我目前有两种Solr排序
I have currently two solr sort
- 名称升序
- 名称降序
我为价格添加了新的Solr排序
I added new solr sort for price
- 价格上涨
- 价格下降
但是我希望我的新Solr排序仅在用户登录后才显示.有人知道吗?谢谢
But I want my new solr sort to only show when the user has logged in. Anyone know? Thanks
推荐答案
步骤1:导入impex以启用价格排序选项
如果您引用任何OOTB商店(apparelstore
),则可以在Impex中看到价格排序(price-asc
)"选项.我在下面突出了Impex.
Step 1: Import impex to enable price sort option
If you refer any OOTB store(apparelstore
), you are able to see Price Sort (price-asc
) option in Impex. I have highlighted Impex below.
对于匿名用户,请勿渲染价格排序.您可以使用JSTL条件来进行检查,如下所述.
Don't render Price sort in case of the anonymous user. You can take help of JSTL condition to check that as I mentioned below.
请注意:以下代码仅供您参考,我尚未对其进行测试
Please Note: Below code is just reference for you, I haven't tested it
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<c:set var="isLoggedInUser" value="false" />
<sec:authorize ifNotGranted="ROLE_ANONYMOUS">
<c:set var="isLoggedInUser" value="true" />
</sec:authorize>
<select id="sortOptions${top ? '1' : '2'}" name="sort" class="form-control">
<option disabled><spring:theme
code="${themeMsgKey}.sortTitle" /></option>
<c:forEach items="${searchPageData.sorts}" var="sort">
<c:if test="${isLoggedInUser || (!isLoggedInUser && !fn:startsWith(sort.code, 'price'))}">
<option value="${sort.code}"
${sort.selected? 'selected="selected"' : ''}>
<c:choose>
<c:when test="${not empty sort.name}">
${sort.name}
</c:when>
<c:otherwise>
<spring:theme code="${themeMsgKey}.sort.${sort.code}" />
</c:otherwise>
</c:choose>
</option>
</c:if>
</c:forEach>
</select>
Impex
定义SolrIndexedProperty
Impex
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 ; ; ; ; ; ; ; ; ; ;
定义可用的排序
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
定义排序字段
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
这篇关于Hybris Solr排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!