Developer forum

Forum » Development » Group.Products returns inactive products

Group.Products returns inactive products

Martin Nielsen
Reply
Hi DW,

When using the api to get all products in a group, you get disable products aswell.

Code:

Dynamicweb.eCommerce.Products.Group grp = new Group( GroupID );
ProductCollection prodCol = grp.Products;


When looping through prodCol i get disabled products which i don't want.

Do i need to loop result and remove disabled items, or what is the best approach?

Regards
 Martin


Replies

 
Vladimir
Reply
This post has been marked as an answer
Hi Martin!

The best approach, one that is most convenient for you:)
1)
     Group grp = new Group(GroupID);
     Product[] prodCol = grp.Products.OfType<Product>().Where(p => p.Active).ToArray();
2)
      Dynamicweb.eCommerce.Products.Product.getProducts(true, GroupID);

or just skip disabled products

Best regards,
Vladimir


Votes for this answer: 0

 

You must be logged in to post in the forum