Chapter 6. Adding the By Brand View feature 119
6.6.3 Get the category ID: JSP implementation
After making category ID settings from the OmniFind Discovery Edition server
side, you can now get the category IDs using OmniFind Discovery Edition APIs.
Go through the tallyFeatures in a loop. For each tallyFeature, check if it is SKU
Category Id. The
SKU Category Id is the label of the sitemap taxonomy id
feature
. If it is, get its values. This is similar to the steps of getting a common
feature information. Example 6-14 shows how to get it with OmniFind Discovery
Edition APIs. Bold text represents the code related to this implementation.
Example 6-14 Get category ID from OmniFind Discovery Edition index
<%
Vector category_IDs = new Vector(); //Save category IDs
Vector category_Links = new Vector(); //Save category links
%>
<%
for (int j = 0; j < tallyFeatures.length; j++){
com.iphrase.runtime.query.result.TallyFeature currentFeature =
tallyFeatures[j];
DrillDownList ddList = new DrillDownList(query, currentFeature,
true);
String currentFeatureLabel = currentFeature.getLabel();
if (!currentFeatureLabel.equals("SKU Category Id")){
continue;
}
for(int listIndex = 0; listIndex < ddList.getCount();
listIndex++){
com.iphrase.onestep.beans.TallyValueHandler valueHandler =
ddList.getValues()[listIndex];
String formatValueStr = formatValue(valueHandler, "", -1, "");
formatValueStr = truncateText(formatValueStr, 100);
category_IDs.addElement(formatValueStr);
category_Links.addElement(valueHandler.getConstraint().toString());
}
}
%>

Get Getting Started with Commerce Module for OmniFind Discovery Edition Customization 101 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.