Get episerver commerce products

Follow this guide http://world.episerver.com/documentation/commerce/get-started-with-commerce/3--creating-a-start-page/ to access trading using episerver. It works great when writing a url for a specific problem.

But say that I have the following tree.

Root directory → testcatalog → testlevel → testproduct 1 and 2

When on testevel (Has a MyNode model, if you look at the tutorial), how do I get all the child products, testproduct 1 and 2? There seem to be 100 ways to do this.

Using the latest copies of episerver and episerver (9).

+4
source share
1 answer

.

var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var products = contentRepository.GetChildren<MyProduct>(Model.ContentLink);

foreach(var product in products)
{
    //Do what you want.
}
+1

All Articles