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?
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
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);
}
}
}
}
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:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.