Multiple catalogs - how to show categories in navigation?
I'am trying to get uCommerce up and running, but having trouble with the structure. I have 3 catalogs with multiple categories.
What I'am trying to make is a normal drop-down navigation with catalogs and other content pages, and their subpages / categories. Below is listing the catalogs, but not their categories ...
List<ProductCatalog> catalogs = UCommerce.Api.CatalogLibrary.GetAllCatalogs();
foreach (ProductCatalog productCatalog in catalogs)
{
<h1>@productCatalog.Name</h1>
@foreach (Category categories in productCatalog) // does not work!
{
<h2>Category display name</h2>
}
}
When doing your foreach you should foreach over the property Categories in productCatalog or use the GetRootCategories method. So your foreach should look like this instead:
@foreach (Category categories in productCatalog.GetRootCategories())
Multiple catalogs - how to show categories in navigation?
I'am trying to get uCommerce up and running, but having trouble with the structure. I have 3 catalogs with multiple categories.
What I'am trying to make is a normal drop-down navigation with catalogs and other content pages, and their subpages / categories. Below is listing the catalogs, but not their categories ...
Any ideas?
Best regards Kim
Hi Kim,
When doing your foreach you should foreach over the property Categories in productCatalog or use the GetRootCategories method. So your foreach should look like this instead:
Best regards Martin
Hi Martin,
Thanks - that worked :)
Best regards
Kim
is working on a reply...