c#-使用Kentico API 9创建多元文化产品
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c#-使用Kentico API 9创建多元文化产品,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2376字,纯文字阅读大概需要4分钟。
内容图文
![c#-使用Kentico API 9创建多元文化产品](/upload/InfoBanner/zyjiaocheng/665/40697b8889f642a69191cd6c1360b239.jpg)
我正在开发一种用于将数据从Sitecore迁移到Kentico的工具.我正在寻找一种使用Kentico API 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?
解决方法:
您应该使用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之后重复此块,即可添加需要添加的任意数量的区域性.
希望这可以帮助.
内容总结
以上是互联网集市为您收集整理的c#-使用Kentico API 9创建多元文化产品全部内容,希望文章能够帮你解决c#-使用Kentico API 9创建多元文化产品所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。