GetProducts function return duplicated products - Ecommerce - Ecommerce - Progress Community

GetProducts function return duplicated products

 Ecommerce

GetProducts function return duplicated products

  • GetProducts function return duplicated products
  • c98c501e-37c1-6deb-a958-ff0000446526_duplicateddata.png

    Hi,

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

    Thanks

     

     

     

  • Hi,

    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: docs.sitefinity.com/for-developers-content-lifecycle


    Regards,
    Seth Cleaver
    Telerik
     
    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