获取产品 Episerver Commerce

nos*_*ock 5 c# asp.net-mvc episerver episerver-commerce

按照本教程http://world.episerver.com/documentation/commerce/get-started-with-commerce/3--creating-a-start-page/开始使用 episerver 商务。将 url 写入特定问题时,它工作正常。

但是说我有以下树。

目录根 -> testcatalog -> testlevel -> testproduct 1 和 2

在 testevel 上时(如果查看教程,有模型 MyNode),我如何获得所有子“产品”,testproduct 1 和 2?似乎有 100 种方法可以做到这一点。

使用最新的外延服务器和外延服务器商务 (9)。

nos*_*ock 2

找到了一种方法。

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

foreach(var product in products)
{
    //Do what you want.
}
Run Code Online (Sandbox Code Playgroud)