120 Getting Started with Commerce Module for OmniFind Discovery Edition
6.6.4 Retrieve category information from WebSphere Commerce
With category ID, we can retrieve more detailed information from WebSphere
Commerce, such as category short description.
Example 6-15 shows you how to retrieve the image and short description from
WebSphere Commerce for the categories containing products of the specified
manufacturer, and set the image hyper links with OmniFind Discovery Edition
APIs for further user searches. The bold text in the example highlights the
important part of the code related to this implementation.
Example 6-15 Display category information with further search links
<!--///////DISPLAY Category one by one//////////////////////-->
<table cellpadding="0" cellspacing="0" border="0" class="t_table"
valign="top" id="table">
<%
for (int j = 0; j < category_IDs.size(); j++){
pageContext.setAttribute("brandCategoryId",category_IDs.elementAt(j));
pageContext.setAttribute("brandCategoryLink",category_Links.elementAt(j
));
CategoryDataBean brandCategoryBean = new
CategoryDataBean();
brandCategoryBean.setCatalogId(pageContext.getAttribute("catalogId").to
String());
brandCategoryBean.setCategoryId(category_IDs.elementAt(j).toString());
com.ibm.commerce.beans.DataBeanManager.activate
(brandCategoryBean, commandContext);
%>
<tr>
<%-- Show category image and short description if
available --%>
<td class="t_img_view">
<!--///////DISPLAY THUMBNAIL//////////////////////-->
<%
Chapter 6. Adding the By Brand View feature 121
String imgFurtherSearchLink =
"javascript:updater('ip_constrain',
encodeURIComponent('"+Tools.escapeJS(category_Links.elementAt(j).toStri
ng())+"'))";
if(!
brandCategoryBean.getDescription().getThumbNail().equals("")) {%>
<a href="<%=imgFurtherSearchLink%>">
<span class="t_img_border">
<img
src=<%=brandCategoryBean.getObjectPath()+brandCategoryBean.getDescripti
on().getThumbNail()%>
alt=<%=brandCategoryBean.getDescription().getShortDescription()%>
border="0" />
</span>
</a>
<%}else{%>
<a href="<%=imgFurtherSearchLink%>">
<img
src="<c:out
value="${jspStoreImgDir}"/>images/NoImageIcon.jpg"
alt="<fmt:message key="No_Image"
bundle="${storeText}"/>"
border="0"/>
</a>
<%}%>
<!--///////END DISPLAY
THUMBNAIL//////////////////////-->
<br/>
<!--///////DISPLAY CATEGORY
NAME//////////////////////-->
<%if(!
brandCategoryBean.getDescription().getShortDescription().equals(""))
{%>
<br/>
<span class="productName">
<a
href="<%=imgFurtherSearchLink%>"><%=brandCategoryBean.getDescription().
getName()%> </a>
</span>
<br/>
<%}%>

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.