Followed this tutorial http://world.episerver.com/documentation/commerce/get-started-with-commerce/3--creating-a-start-page/ to get going with episerver commerce. It works fine when writing the url to a specific problem.
But say that I have the following tree.
Catalog Root -> testcatalog -> testlevel -> testproduct 1 and 2
When on testevel (Has the model MyNode if looking at the tutorial), how do I get all child "products", testproduct 1 and 2? It seems like there are 100 ways of doing this.
Using latest episerver and episerver commerce (9).
Found a way of doing it.
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var products = contentRepository.GetChildren<MyProduct>(Model.ContentLink);
foreach(var product in products)
{
//Do what you want.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With