Try Now
More in this section

Forums / Developing with Sitefinity / How to get ratings and reviews on a products by api?

How to get ratings and reviews on a products by api?

3 posts, 0 answered
  1. Ajai
    Ajai avatar
    15 posts
    02 Mar 2015
    12 May 2015
    Link to this post

    Hi all,

    i am working on sitefinity version 7.0.

    I am using eCommerce section in that. I have created the products and enabled the comments and review on products.So users can review and comment on products.

     How can i retrieve the ratings and reviews on a particular product by using Api?



  2. OC
    OC avatar
    129 posts
    17 Nov 2004
    25 May 2015
    Link to this post
  3. Kaloyan
    Kaloyan avatar
    272 posts
    25 Oct 2016
    26 May 2015
    Link to this post
    Hello Guys,

    What you need to use is comments API. I have a sample for news items based on the last code snippet provided in the following documentation article. The approach for products is just the same.

    Query comments

    NewsManager manager = NewsManager.GetManager();
                var newsItem = manager.GetNewsItems().Where(t => t.Title == "Test" && t.Status == ContentLifecycleStatus.Live).FirstOrDefault();
                // Gets an instance of the comments service
                var cs = SystemManager.GetCommentsService();
                //instantiate comment filter
                var commentFilter = new CommentFilter();
                //add filter by News
                //get the comment with the specified commentKey
                var comments = cs.GetComments(commentFilter);
                var ratings = cs.GetThread(newsItem.Id + "_" + CultureInfo.CurrentCulture.Name.ToString() + "_review" ).AverageRating.Value;

    You can find more information about the threadKey that you have use as parameter for GetThread method directly from sf_cs_threads table.

    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
3 posts, 0 answered