Posted on 06/06/2016 08:35:47
Hi Imar, this is the way we traverse EcomGroups :-)
@helper RenderNavigation_ECOM(Dynamicweb.eCommerce.Products.GroupCollection groupCollection, int lvl, int productPageID)
{
groupCollection = (groupCollection == null)
? new Dynamicweb.eCommerce.Shops.Shop((string)Dynamicweb.Frontend.PageView.Current()
.Area.get_Value("AreaEcomShopID"))
.get_TopLevelGroups((string)Dynamicweb.Frontend.PageView.Current()
.Area.get_Value("AreaEcomLanguageID"))
: groupCollection;
foreach (var group in groupCollection)
{
string li_class = string.Format("lvl{0}", lvl.ToString());
<li class="@li_class">
@{
string link = string.Format("/Default.aspx?id={0}&GroupID={1}", productPageID.ToString(), group.ID);
if (group.Subgroups.Count > 0)
{
link = "#";
}
}
<a href="@link" class="@li_class">@group.Name</a>
@if (group.Subgroups.Count > 0)
{
string ul_class = string.Format("lvl{0}", (lvl + 1).ToString());
<ul class="@ul_class">
@RenderNavigation_ECOM(group.Subgroups, lvl+1, productPageID) // recursive calling RenderNavigation_ECOM()
</ul>
}
</li>
}
}
/Dmitrij