Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Get product stock-quantity from freemarker
Hello everyone! I am creating a search widget template and I am using liferay-commerce-ui taglib. I see that there is a tag for availability-label. It shows if the product is available or not. But I'd like to show also the stock-quantity. I saw in a view.jsp file that it is done with cpContentHelper.getStockQuantity. But I am not able to use it in my freemarker template. Do u know how to do it?
well, I did it! I got the stock quantity and also the booked quantity. That's how:
<#assign ciwils = serviceLocator.findService("com.liferay.commerce.inventory.service.CommerceInventoryWarehouseItemLocalService")
cibqls = serviceLocator.findService("com.liferay.commerce.inventory.service.CommerceInventoryBookedQuantityLocalService")
skus = curCPCatalogEntry.getCPSkus() />
<#list skus as sku>
<#if sku.isPublished()>
${ciwils.getStockQuantity(themeDisplay.getCompanyId(),sku.getSku()) - cibqls.getCommerceBookedQuantity(themeDisplay.getCompanyId(),sku.getSku())}
</#if>
</#list>