Thursday, September 4, 2014

Ordering Categories By Sequence in Left Navigation

Without adding the logic below in CategoryFacetDisplay.jspf, OOB gets the categories by quantity product under each category by default to change that ordering to by sequence no in CATGRPREL. You need to add the following code to reorder the list. This would fix the left navigation.

This is a good example of ArrayList manipulation in JSP

<wcf:useBean var="sequenceBasedFacetFieldList" classname="java.util.ArrayList"/>
<wcbase:useBean id="currentCategoryDataBean" classname="">
<c:set target="${currentCategoryDataBean}" property="categoryId" value="${WCParam.categoryId}" />
<c:forEach var="catDB" items="${currentCategoryDataBean.subCategories }">
<c:forEach var="item1" items="${facetField.entry }">
<c:if test="${item1.value == catDB.categoryId }">
<wcf:set target="${sequenceBasedFacetFieldList}" value="${item1 }"/>
<wcf:useBean var="categoryFacetList" classname="java.util.ArrayList"/>

<c:forEach var="item" items="${sequenceBasedFacetFieldList}" varStatus="aStatus">