Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Tommy Albinsson 121 posts 254 karma points
    May 04, 2012 @ 11:27
    Tommy Albinsson
    0

    Getting products from specific ProductCatalogGroup

    Hi,

    In a new website that we are developing we would like to get all products from a specific ProductCatalogGroup. The case is that we have two ProductCatalogGroups. One that contains all the products from our erp, and the second one contains all the products that should be available on the site. 

    So, is there a way to get all the products from on specific ProductCatalogGroup? Or when querying Product.All(), can you check i the product belongs to a specific ProductCatalogGroup?

     

    // Tommy

  • Tommy Albinsson 121 posts 254 karma points
    May 04, 2012 @ 11:37
    Tommy Albinsson
    0

    Would this do it? I think that the number of products I am getting back from this is to high.

                var products = new List<Product>();

                var productCatalogGroup = ProductCatalogGroup.FirstOrDefault(pcg => pcg.Name == "ProductCatalogGroup");

     

                foreach (var productCatalog in productCatalogGroup.ProductCatalogs)

                {

                    if (!productCatalog.Deleted)

                    {

                        foreach (var category in productCatalog.Categories)

                        {

                            if (!category.Deleted)

                            {

                                products.AddRange(category.Products);

                            }

                        }

                    }

                }    

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 09, 2012 @ 10:16
    Søren Spelling Lund
    0

    Hi Tommy,

    Just following up here as well for completeness sake:

    You can get at all the products in a specific store via category => catalog => catalog group. Here's a query that does just that:

    var myProductCatalogGroup = ProductCatalogGroup.SingleOrDefault(x => x.Name == "uCommerce");
    var products = Product.All().Where(x => x.CategoryProductRelations.Any(y => y.Category.ProductCatalog.ProductCatalogGroup == myProductCatalogGroup));
Please Sign in or register to post replies

Write your reply to:

Draft