// This method demonstrates usage of the categoy configuration objects
internal void UseCategoryConfiguration(string catalogName, string categoryName)
{
ProductCatalog productCatalog = this.catalogContext.GetCatalog(catalogName);
// Use the category configuration object to configure the properties that are
// initialized in the category object. These properties will be preloaded by the catalog server
// All other properties will be lazy initialized.
CategoryConfiguration categoryConfiguration = new CategoryConfiguration();
categoryConfiguration.LoadChildProducts = true;
categoryConfiguration.ChildProducts.SearchOptions = new CatalogSearchOptions();
categoryConfiguration.ChildProducts.SearchOptions.ClassTypes = CatalogClassTypes.ProductClass | CatalogClassTypes.ProductFamilyClass;
categoryConfiguration.ChildProducts.SearchOptions.SetPaging(1, 20);
Category category = productCatalog.GetCategory(categoryName, categoryConfiguration);
// Iterating the Product Collection
foreach (Product product in category.ChildProducts)
{
// Accessing the display name of the product
Console.WriteLine(product.DisplayName);
}
foreach (Category parentCategory in category.ParentCategories)
{
// Accessing the display name of the category
Console.WriteLine(parentCategory.DisplayName);
}
// Accessing category relationships
foreach (CatalogRelationshipsDataSet.CatalogRelationship relationship in category.RelatedCategories.CatalogRelationships)
{
Console.WriteLine(relationship.RelationshipName);
Console.WriteLine(relationship.RelationshipDescription);
}
}