Developer forum

Forum » Templates » Ecommerce groups and assortments

Ecommerce groups and assortments

Martin Grønbekk Moen
Reply

Im trying to get all ecommerce groups using Razor, and it is working just fine, I get all my groups.
The problem is that I get groups that should not been visible due to assortment rules.

This is how I get my GroupCollection.

groupCollection = new Dynamicweb.eCommerce.Shops.Shop((string)Dynamicweb.Frontend.PageView.Current().Area.get_Value("AreaEcomShopID")).TopLevelGroups;

By using this I get all top level groups, but I would like to hide those without products due to assortment rules. So I try to add this in my loop.

groupCollection.Where(x => x.HasProducts())

But it does not work. It does not look like it takes assortments into consideration. When I click on the category to see products I dont see them, so the product listing is working fine.


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Martin

That looks like some very expensive API calls - be careful when doing that. You x.HasProducts can result in a query...

You are using a part of the API that is also handling the backend, so taking out groups that are in the current users assortment is of course not done.

So the basic API gives you 'raw' data - and removing groups and products in context of assortments are handled in the frontend. So the navigation handler and product catalog module is where the assortment is implemented.

Can you tell a bit about what you are trying to accomplish - There might be a better way of doing it.

BR Nicolai

 
Martin Grønbekk Moen
Reply

Ok, I understand.

I first tried to use the regular eCom loops, but since I have my ecommerce menu in my master page I was not able get any data out of it.
Guess it has to be in the same context as the eCom module?
 

 
Nicolai Høeg Pedersen
Reply

Yes, and the loggeed in user of course.

 

You must be logged in to post in the forum