GetProducts function return duplicated products

Posted by Community Admin on 05-Aug-2018 04:47

GetProducts function return duplicated products

All Replies

Posted by Community Admin on 12-Feb-2015 00:00

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

 

 

 

Posted by Community Admin on 20-Feb-2015 00:00

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
 

This thread is closed