2016-07-14 6 views
3

私はSitecoreからKenticoへデータを移行するためのツールを開発しています。私は、Kentico API 9を使用して2つの異なる文化を持つ製品を作成する方法を探しています。Sitecoreからデータを抽出し、APIを使用してKenticoに保存したいと考えています。Kentico API 9を使用したMulticulture製品の作成

私は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にデータを移行する方法をお勧めしますか?

答えて

3

あなたは最初の文化の中でページを保存し、ページに他の文化を追加するDocumentHelper.InsertNewCultureVersion()を使用するCMS.DocumentEngineに位置DocumentHelper.InsertDocument()を使用する必要があります。あなたのコードはので、それらの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に追加して、追加する必要があるカルチャの数を入力します。

これが役に立ちます。

関連する問題