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: RE: Widget Template (Search Results)
Hello, I'm creating a Widget Template (Search Results Template). I'm working with CPCatalogEntry and CPDefinitionLocalService classes and I'm wondering how to get the list of specifications of a product.
Liferay Community Edition Portal 7.4.3.13 CE GA13
Hi Gennaro, is your question really about ow to use the CP services and models to get all product specifications, or is there something about doing it in a Widget Template for the Search Results widget that is giving you trouble?
Hello Russell, thank you for your interest. No, I'm not getting troubles because I'm doing it in a Widget Template.
I actually don't know how to get the specifications list starting from a product (CPCatalogEntry object). In particular my question was about the widget because in it I have this CPCatalogEntry list:
<#if entries?has_content>
<#list entries as curCPCatalogEntry>
//do something
</#list>
</#if>
I did it! this is the my code to get specifications:
<#if entries?has_content>
<#list entries as curCPCatalogEntry>
<#assign CPDefinitionLocalService = serviceLocator.findService("com.liferay.commerce.product.service.CPDefinitionLocalService")
CPDefinition = CPDefinitionLocalService.getCPDefinition(curCPCatalogEntry.getCPDefinitionId())
CPDefinitionSpecificationOptionValues = CPDefinition.getCPDefinitionSpecificationOptionValues()
/>
<#list CPDefinitionSpecificationOptionValues as cpdsov>
<#assign cpSpecificationOption = cpdsov.getCPSpecificationOption() />
<span>${cpSpecificationOption.getTitle(locale)}</span>
<span>${cpdsov.getValue()}</span>
</#list>
</#list>
</#if>
Great! You could make an answer with same content as your last comment, then accept it as the answer.
I did it! this is my code to get specifications:
<#if entries?has_content>
<#list entries as curCPCatalogEntry>
<#assign CPDefinitionLocalService = serviceLocator.findService("com.liferay.commerce.product.service.CPDefinitionLocalService")
CPDefinition = CPDefinitionLocalService.getCPDefinition(curCPCatalogEntry.getCPDefinitionId())
CPDefinitionSpecificationOptionValues = CPDefinition.getCPDefinitionSpecificationOptionValues()
/>
<#list CPDefinitionSpecificationOptionValues as cpdsov>
<#assign cpSpecificationOption = cpdsov.getCPSpecificationOption() />
<span>${cpSpecificationOption.getTitle(locale)}</span>
<span>${cpdsov.getValue()}</span>
</#list>
</#list>
</#if>
Powered by Liferay™