How to modify a product property in JSP code?
Hi all,
I'm trying to obtain a property of a product, and it is done with the following lines of code:
"String combo = product.getProperty("componentBox", String.class);
out.println(combo);"
but, now I want do a setProperty of this product to modify the componentBox field, but the API product haven't this function and my questions is... How could I modify a property of a product in CRXDE with code in .jsp?
Is it possible to do this?
Could you give me any example?
Thanks a lot for your time.
Best regards.
<%@page session="false"%> <% %><%@ include file="/libs/foundation/global.jsp" %><% %><%@ page contentType="text/html; charset=utf-8" import=" com.adobe.cq.commerce.api.CommerceSession, com.adobe.cq.commerce.common.CommerceHelper, com.adobe.cq.commerce.api.Product, info.geometrixx.commons.util.GeoHelper, com.adobe.cq.commerce.api.CommerceService, java.util.Locale"%><% final Locale pageLocale = currentPage.getLanguage(false); final String language = pageLocale.getLanguage(); CommerceService commerceService = resource.adaptTo(CommerceService.class); CommerceSession session = commerceService.login(slingRequest, slingResponse); final Page listItem = (Page)request.getAttribute("listitem"); final Product product = CommerceHelper.findCurrentProduct(listItem); if (product != null) { final String pagePath = listItem.getPath(); final String title = product.getTitle(language); final String price = session.getProductPrice(product); String combo = product.getProperty("componentBox", String.class); out.println(combo); %><li> <a href="<%= xssAPI.getValidHref(pagePath) %>.html" title="<%= xssAPI.encodeForHTMLAttr(title) %>" onclick="CQ_Analytics.record({event: 'listItemClicked', values: { listItemPath: '<%= xssAPI.encodeForJSString(pagePath) %>' }, collect: false, options: { obj: this }})"> <img src="<%= xssAPI.getValidHref(product.getThumbnailUrl(160)) %>" width="160" height="120" alt="<%= xssAPI.encodeForHTMLAttr(title) %>"/> <h4><%= xssAPI.encodeForHTML(title) %></h4> <% if (GeoHelper.notEmpty(price)) { %> <p><%= xssAPI.encodeForHTML(price) %></p><% } %> </a> </li><% } %>