Page 1 of 1

How to add product rating to productListItem template?

Posted: Tue Jul 29, 2014 2:04 am
by gowthamgutha
I would like to add product rating in the productListItem template? How could I do that?
In my solr documents, I have added a field called product_rating which is like this..

<field name="product_rating" type="double" indexed="true" stored="true" />

Now, I would like to now how could I get this field in the productListItem template? The productListItem, I can access only product class object, but how could I access the product_rating?

Thanks in advance. Hope you will reply as soon as possible.

Re: How to add product rating to productListItem template?

Posted: Tue Jul 29, 2014 3:11 pm
by phillipuniverse
How are you populating that product_rating field in the Solr index in general? That would be one way to display the value of that.

If it is some sort of aggregate that you do not want to re-compute though, you could instead modify the findProducts() method in SolrSearchServiceImpl and add some logic with parsing out SolrDocuments.

Re: How to add product rating to productListItem template?

Posted: Wed Jul 30, 2014 9:55 am
by gowthamgutha
Here is the actual snippet of the SolrSearchServiceImpl..

Code: Select all

        List<Product> products = getProducts(responseDocuments);

        ProductSearchResult result = new ProductSearchResult();
        result.setFacets(facets);
        result.setProducts(products);
        setPagingAttributes(result, numResults, searchCriteria);


The Product contains no product_rating property? Where should I put this product_rating so that I could get it in the thymeleaf template?

Thanks in advance. Hope you will reply as soon as possible.