Hi,
I've got a pretty simple group structure in eCom, but making it work in frontend is quite hard...
- Group1
- Subgroup1
- Subgroup2
- Group2
- Subgroup3
- Sugrroup4
Important! No groups will ever be present more that one place in this structure!
In the frontend we would like to list them like this:
Initial page:
Group1
Group2
Etc.
On click on a level1 group we would like all products from the level2 groups (child groups of that level1 group) listed, but grouped by their level2 group.
- Subgroup1
- Product1
- Product2
- Product3
- Subgroup2
- Product4
- Product5
- etc.
I have managed to get the products grouped, but I can't seem to access the sort order from the backend. I know that the comment on this earlier has been: "it doesn't make sense to have that available because groups can be in more than one location in the group tree"... But in my case it sure does!
@{ var groups = GetLoop("Products").GroupBy(g => g.GetString("Ecom:Product.PrimaryOrFirstGroupID"));
{
{
if (group.First()==p) {
var agroups = p.GetLoop("AssociatedGroups");
foreach (var agroup in agroups.Where(g => g.GetString("Ecom:Group.ID") == group.Key)) {
<h3>@agroup.GetString("Ecom:Group.Name")</h3>
}
}
@foreach (var p in group)
{
here I have my code for each product
}
</ul>
}
}