我正在开发一个工具,用于将数据从Sitecore迁移到Kentico。我正在寻找一种方法来使用Kentico 9创建具有两种不同文化的产品。我想从Sitecore中提取数据,并使用API将其存储到Kentico。
我查阅了Kentico文档,它为我们提供了创建产品的代码:
// Gets a department
DepartmentInfo department = DepartmentInfoProvider.GetDepartmentInfo("NewDepartment", SiteContext.CurrentSiteName);
// Creates a new product object
SKUInfo newProduct = new SKUInfo();
// Sets the product properties
newProduct.SKUName = "NewProduct";
newProduct.SKUPrice = 120;
newProduct.SKUEnabled = true;
if (department != null)
{
newProduct.SKUDepartmentID = department.DepartmentID;
}
newProduct.SKUSiteID = SiteContext.CurrentSiteID;
// Saves the product to the database
// Note: Only creates the SKU object. You also need to create a connected Product page to add the product to the site.
SKUInfoProvider.SetSKUInfo(newProduct);但是我不知道如何创建一个具有不同文化附件的多元文化产品。
有人会帮助或推荐一种不同的方法将数据从Sitecore迁移到Kentico吗?
发布于 2016-07-14 20:11:50
您应该使用位于CMS.DocumentEngine中的DocumentHelper.InsertDocument()以第一个区域性保存页面,然后使用DocumentHelper.InsertNewCultureVersion()将其他区域性添加到页面。您的代码能够创建SKU,因此要为这些SKU创建产品页面,您应该添加以下内容:
TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
//Get a parent node, under which the product pages will be created.
//Replace "/Store/Products" with page alias of the parent page to use.
TreeNode parentNode = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/Store/Products", "en-us");
//Create a new product page
TreeNode node = TreeNode.New("CMS.Product", tree);
//Set the product page's culture and culture specific properties, according to your needs
node.DocumentCulture = "en-us";
node.DocumentName = "ProductPage - English";
node.NodeSKUID = newProduct.SKUID;
//Save the page
DocumentHelper.InsertDocument(node, parentNode, tree);
//Set the product pages culture and culture specific properties for another culture
node.DocumentCulture = "es-es";
node.DocumentName = "ProductPage - Spanish";
node.NodeSKUID = newProduct.SKUID;
//Save the new culture version
DocumentHelper.InsertNewCultureVersion(node, tree, "es-es"); 要将附件添加到文档,请在将文档保存到数据库之前使用DocumentHelper.AddAttachment()。然后,对于需要添加的任意数量的区域性,只需在DocumentHelper.InsertDocument之后重复该块。
希望这能有所帮助。
https://stackoverflow.com/questions/38369889
复制相似问题