More in this section
Forums / Ecommerce / GetProducts function return duplicated products

GetProducts function return duplicated products

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. phong
    phong avatar
    3 posts
    27 Jan 2015
    12 Feb 2015
    Link to this post


    I used function GetProducts().ToList(); to get all products butI got duplicated products with different IDs. What is correct data I should get.





  2. Seth Cleaver
    Seth Cleaver avatar
    24 posts
    02 Aug 2016
    20 Feb 2015
    Link to this post

    The reason for this is that when you use GetProducts() you are getting all products in both with Live and Master state. You need to specify whether you want the master version of the item or the live version (the version that is currently published) like so:

    .GetProducts().Where(i => i.Status = ContentLifecycleStatus.Live && i.Visibility = true);

    The above with get all the live products that are visible (note that you can have a live version that has been unpublished so to only get the live item versions that are published you need to set the visibility = true)

    You might like to read this article to get some background info:

    Seth Cleaver
    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
2 posts, 0 answered