The way Kentico ties the CMS to the EMS(E-Commerce management system) is not instantly obvious.
It tries to keep them relatively separate. When you create a product instance in the tree, Kentico does two things:
Stores it's ecommerce-relevant data as in a new row
COM_SKU
table (accessible in code as the SKUInfo object)Creates a new
CMS_Tree
row (as well as a matchingCMS_Document
row) of document type Product (or your document type inherited from product)
The database only holds one piece of info to link the two tables - the CMS_Tree.SKUNodeID, which is null
for documents that aren't also SKU products.
Either of these tables lets you add custom fields via the Kentico Site Manager CMS. You can create custom fields within the Document Type for the product, or as custom fields for the SKU (within SiteManager->Development->System Tables->COM_SKU).
Depending on whether your information is relevant to the EMS or not should decide where you store it.
Looking at your question, you've already defined the custom fields within the Document part of the object, so would access them using:
TreeNode productTreeNode = TreeHelper.SelectSingleNode("/Home/TreeNode/Path/To/Product");
object customValue = productTreeNode.GetValue("[your_custom_field_name]");
However, If you needed to access custom fields you'd defined within the ecommerce part (the SKUInfo object), it's slightly more difficult. If you have access to the skuID:
SKUInfo skuObject = SKUInfoProvider.getSKUInfo(skuID);
skuObject.GetValue("[your_custom_field_name]");
If you have access to the TreeNode
of the product, it should be castable as a SKUTreeNode
, and the SKUInfo
object (as well as its skuID) accessed from there:
SKUTreeNode skuNode = CurrentDocument as SKUTreeNode;
if( skuNode != null ) {
skuNode.SKU.SKUID;
}
Also note:
There can be multiple tree nodes that are assigned a single SKU product. You can also create a product in the tree without also creating a matching SKU object. (There should be a checkbox when creating the instance within the CMS)