complete list of categories and products on homepage

Hi

The homepage of our ecommerce site has to list all categories, then under each category heading it should list every single product. The problem I'm having is that all the categories are loaded into a menu but I can't figure out how to retrieve this list without using the CatalogSiteMapProvider.

Could somebody point me in the direction of what objects I need to start with in order to build the list? I've been looking at the CatalogContext object, but I'm pretty sure it's not the right place to start.

I've got a really short deadline, and I've pretty much been told that the starter site isn't suitable for our requirements.

Thanks for any help in advance.

Paul Tew

[718 byte] By [PaulTew] at [2008-2-27]
# 1

Something like this:

CategoryCollection categories =

CommerceContext.Current.CatalogSystem.GetCatalog("MyCatalog").GetRootCategory().ChildCategories;

foreach(Category category in categories)

{

// show category

Response.Write(category.DisplayName);

foreach(Product product in category.ChildProducts)

{

// show product

Response.Write(product.DisplayName);

}

}

That should get you pointed in the right direction. For performance sake you may want to look at CategoryConfiguration and ProductConfiguration to limit what information is returned from the database. If you have multiple catalogs you'll need to combine the category lists in some way (and iterate over CommerceContext.Current.CatalogSystem.GetCatalogs() or CommerceContext.Current.GetCatalogsForUser();

JoeWasson-MSFT at 2007-9-4 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 2

Thanks very much it is a great help. I've used the ProductUri class in order to set up the links to the product information page.

Our site will only have a single catalog, and it won't be customised for each user thankfully.

PaulTew at 2007-9-4 > top of Msdn Tech,Commerce Server,Commerce Server 2007...