0

我有一系列网站,需要用一个简单的目录和该目录中的 3 种基本产品类型来更新它们。有没有办法以编程方式创建产品类型(仅指定名称和类型),然后创建包含这 3 种类型的目录?

我正在使用 8.0.1 SP1。

4

1 回答 1

2

虽然您最好只在第一个实例中创建一次产品类型,然后将包复制到其他服务器以节省时间,但通过代码执行此操作的要点如下:

    //Put user code to initialize the page here
    Ektron.Cms.Commerce.ProductTypeApi ptapi = new Ektron.Cms.Commerce.ProductTypeApi();
    Ektron.Cms.Commerce.ProductTypeData ptdata = new Ektron.Cms.Commerce.ProductTypeData();
    ptdata.Title = "Title of Product Type";
    //Define additional attributes and properties to your new product type below
    //ptdata.
    ptapi.Add(ptdata);

    //Now that your product type is created assign it to a folder (Automatically giving admin access to create)
    Ektron.Cms.Framework.Organization.FolderManager fmanager = new Ektron.Cms.Framework.Organization.FolderManager(Ektron.Cms.Framework.ApiAccessMode.Admin);
    Ektron.Cms.FolderData fdata = new Ektron.Cms.FolderData();
    Ektron.Cms.Content.EkContent ekcontent = new Ektron.Cms.Content.EkContent();

    long idofproducttype = 5;

    Ektron.Cms.XmlConfigData xmlconfig = ekcontent.GetXmlConfigurationData(idofproducttype);
    fdata.Name = "Catalog Name";
    fdata.Type = Ektron.Cms.Common.EkEnumeration.FolderType.Catalog;
    fdata.XmlConfiguration[0] = xmlconfig;
    fmanager.Add(fdata);
于 2012-06-29T14:17:21.673 回答