Using Accelerator Fields to set Images on Product Displays.
So you've got a marketing "genius" who would like to place variable images on various products throughout the website. This can be quite simply done with the use of a bean. You can use the "com.ibm.commerce.catalog.beans.ProductDataBean" to get the field information at the product level.
Simply declare your bean:
<wcbase:usebean id="product" classname="com.ibm.commerce.catalog.beans.ProductDataBean" scope="request"></wcbase:usebean>
Then wherever you need to access a field on the page you can call the bean and field like so:
<c:if test="${product.field4 == 'EXCLUSIVE'}">
<div><img src="<c:out value="${jspStoreImgDir}" />Exclusive.jpg" alt="Internet Exclusive" /></div>
</c:if>
Per the above example any product with the word "EXCLUSIVE" in field 4 will display the "Exclusive.jpg" image.
You can also use this logic in a choose statement and display different images.
e.g.
<c:choose>
<c:when test="${product.field4 == 'EXCLUSIVE'}">
<div><img src="<c:out value="${jspStoreImgDir}" />Exclusive.jpg" alt="Internet Exclusive" /></div>
</c:when>
<c:when test="${product.field4 == 'INTRODUCTORY OFFER'}">
<div><img src="<c:out value="${jspStoreImgDir}" />IntroOffer.jpg" alt="Introductory Offer" /></div>
</c:when>
<c:otherwise>
<div><img src="<c:out value="${jspStoreImgDir}" />Sale.jpg" alt="Sale" /></div>
</c:otherwise>
</c:choose>
Print This Post