Product details sample code for supporting entitled items
You can use the following sample code on your Madisons starter store Product Details page to enable the page to handle information for entitled products. This information enables the page to support color swatches, full image paths, angle image paths, and attribute data for products.
This code is used as part of enabling a starter store to use the Commerce Composer framework for designing and managing store page layouts. By default, the Product Details page for the Aurora starter store that is available with WebSphere Commerce Feature Pack 7 or higher supports the use of the Commerce Composer framework.
Copy
the following code within the div
element that includes
the attribute id=entitledItem_
. Add this code to
the corresponding location in the ProductDisplay.jsp JSP
file for your Madisons starter store.
<c:set var="catalogEntryID" value="${catalogEntryDetails.uniqueID}" />
<c:set var="entitledItems" value="${catalogEntryDetails.sKUs}"/>
<c:set var="numberOfSKUs" value="${catalogEntryDetails.numberOfSKUs}"/>
<c:set var="attributes" value="${catalogEntryDetails.attributes}"/>
<div id="entitledItem_<c:out value='${catalogEntryID}'/>" style="display:none;">
[
<c:if test="${type == 'product'}">
<%-- SwatchCode start --%>
<c:if test="${!empty entitledItems}">
<%-- Find out if we have angle image attachments in the product, if there is then we should retrieve that for all items. --%>
<%-- Otherwise, we can use a lighter service. --%>
<c:set var="hasAngleImages" value="false" />
<c:set var="allAttachments" value="${catalogEntryDetails.attachments}" />
<c:forEach var="anAttachment" items="${allAttachments}">
<c:if test="${'ANGLEIMAGES_THUMBNAIL' eq anAttachment.usage}">
<c:set var="hasAngleImages" value="true" />
</c:if>
</c:forEach>
</c:if>
<%-- SwatchCode end --%>
<c:forEach var='entitledItem' items='${entitledItems}' varStatus='outerStatus'>
<c:if test="${entitledItem.buyable eq 'true'}">
<c:set var="sku" value="${entitledItem}"/>
<c:set var="skuID" value="${entitledItem.uniqueID}"/>
{
"catentry_id" : "<c:out value='${skuID}' />",
"Attributes" : {
<c:set var="hasAttributes" value="false"/>
<c:forEach var="definingAttrValue2" items="${sku.attributes}" varStatus="innerStatus">
<c:if test="${definingAttrValue2.usage == 'Defining'}">
<c:if test='${hasAttributes eq "true"}'>,</c:if>
"<c:out value="${fn:replace(definingAttrValue2.name, search01,
replaceStr01)}_${fn:replace(fn:replace(definingAttrValue2.values[0].value, search01,
replaceStr01), search, replaceStr)}" />":"<c:out value='${innerStatus.count}' />"
<c:set var="hasAttributes" value="true"/>
</c:if>
</c:forEach>
},
<%-- SwatchCode start --%>
<c:set var="catalogEntryViewItemDetails" value="${catalogEntryDetails.sKUs}"/>
<c:forEach items = "${catalogEntryViewItemDetails}" var="itemDetail">
<c:if test="${!empty itemDetail.thumbnail}">
<c:choose>
<c:when test="${(fn:startsWith(itemDetail.thumbnail, 'http://') || fn:startsWith(itemDetail.thumbnail, 'https://'))}">
<wcst:resolveContentURL var="thumbnailImage" url="${itemDetail.thumbnail}"/>
</c:when>
<c:otherwise>
<c:set var="thumbnailImage" value="${itemDetail.thumbnail}" />
</c:otherwise>
</c:choose>
<c:set var="itemFullImagePath" value="${fn:replace(thumbnailImage, productThumbnailImage, productMasterImage)}" />
</c:if>
<c:if test="${empty itemFullImagePath}">
<c:set var="itemFullImagePath" value="${hostPath}${jspStoreImgDir}images/NoImageIcon.jpg"/>
</c:if>
<c:if test="${itemDetail.uniqueID == entitledItem.uniqueID}">
"ItemImage" : "<c:out value='${itemFullImagePath}' />",
"ItemImage467" : "<c:out value='${itemFullImagePath}' />",
"ItemThumbnailImage" : "<c:out value='${fn:replace(itemFullImagePath, productMasterImage, productThumbnailImage)}' />"
<c:if test="${fn:length(itemDetail.attachments) > 0}">
,"ItemAngleThumbnail" : {
<c:set var="imageCount" value="0" />
<c:forEach var="itemAttachment" items="${itemDetail.attachments}" varStatus="status1">
<c:if test="${itemAttachment.usage == 'ANGLEIMAGES_THUMBNAIL'}">
<c:if test='${imageCount gt 0}'>,</c:if>
<c:set var="imageCount" value="${imageCount+1}" />
<c:choose>
<c:when test="${(fn:startsWith(itemAttachment.attachmentAssetPath,
'http://') || fn:startsWith(itemAttachment.attachmentAssetPath, 'https://'))}">
<wcst:resolveContentURL var="resolvedPath" url="${itemAttachment.attachmentAssetPath}"/>
</c:when>
<c:otherwise>
<c:set var="resolvedPath" value="${env_imageContextPath}/${itemAttachment.attachmentAssetPath}" />
</c:otherwise>
</c:choose>
"image_${imageCount}" : "<c:out value='${resolvedPath}' />"
</c:if>
</c:forEach>
},
"ItemAngleThumbnailShortDesc" : {
<c:set var="imageCount" value="0" />
<c:forEach var="itemAttachment" items="${itemDetail.attachments}" varStatus="status1">
<c:if test="${itemAttachment.usage == 'ANGLEIMAGES_THUMBNAIL'}">
<c:if test='${imageCount gt 0}'>,</c:if>
<c:set var="imageCount" value="${imageCount+1}" />
"image_${imageCount}" : "<c:out value='${itemAttachment.identifier}' />"
</c:if>
</c:forEach>
},
"ItemAngleFullImage" : {
<c:set var="imageCount" value="0" />
<c:forEach var="itemAttachment" items="${itemDetail.attachments}" varStatus="status2">
<c:set var="imgSource" value="${itemAttachment.attachmentAssetPath}" />
<c:if test="${itemAttachment.usage == 'ANGLEIMAGES_FULLIMAGE'}">
<c:if test='${imageCount gt 0}'>,</c:if>
<c:set var="imageCount" value="${imageCount+1}" />
<c:choose>
<c:when test="${(fn:startsWith(imgSource, 'http://') || fn:startsWith(imgSource, 'https://'))}">
<wcst:resolveContentURL var="imgSource" url="${imgSource}"/>
</c:when>
<c:otherwise>
<c:set var="imgSource" value="${env_imageContextPath}/${imgSource}" />
</c:otherwise>
</c:choose>
"image_${imageCount}" : "<c:out value='${imgSource}' />"
</c:if>
</c:forEach>
}
</c:if>
</c:if>
</c:forEach>
<%-- SwatchCode end --%>
}<c:if test='${!outerStatus.last}'>,</c:if>
</c:if>
</c:forEach>
</c:if>
<c:if test="${type == 'package' || type == 'bundle' || type == 'item' || type == 'dynamickit'}">
{
"catentry_id" : "<c:out value='${catalogEntryID}'/>",
"Attributes" : { }
}
</c:if>
]
</div>