Connecting Page to SKU Clears SKUName

Leif Anderson asked on February 11, 2026 16:45

We set up ecommerce products, connecting them to a custom page (called "ProductSku"), which contains the product's content.

However, I found a bug with a script that we wrote to do this work... where when you make a new SKUInfo in Kentico, you can add the SKUName, but when it gets associated to the ProductSku page (TreeNode), it clears out the name from the database and the UI. I played around with adding the data back in, and I can add it back... but then it only shows in the Database, not the Kentico Admin UI. The problem with it not showing in the UI is if a user wants to do any bulk actions (like translate many products to another language), then we're getting an error along the line of "Cant insert SKU into database with SKUName null".

Kentico Version: v13.0.193

Here's some example code... This is a test script I wrote to try to suss out what was going on. - "STEP 3" creates a new SKU (after that, the SKU is in the database and has a name) - "STEP 4" assoicates this new SKU with the given node (at this point, the SKU Name is blanked out) - "STEP 5" sets the SKU Name again, and this does work... it goes to the database, even while connected to the page, but it doesn't show in the UI.

int siteID = 14;
int testNodeID = 46114;
int originalSKUID = 0;
int newTestSKUID = 0;
TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);

try
{
// STEP 1: Get the TreeNode with ID 46114
Logger.WriteLine($"[SKU Association Test] --> Getting TreeNode with ID {testNodeID}...");
TreeNode testNode = tree.SelectNodes()
    .WhereEquals("NodeID", testNodeID)
    .FirstOrDefault();

if (testNode == null)
{
    Logger.WriteLine($"[SKU Association Test] --> ERROR: Could not find TreeNode with ID {testNodeID}");
    return;
}

Logger.WriteLine($"[SKU Association Test] --> Found TreeNode: {testNode.NodeName} (Type: {testNode.ClassName})");
Logger.WriteLine($"[SKU Association Test] --> Current NodeSKUID: {testNode.NodeSKUID}");

// STEP 2: Save the original SKU relationship
originalSKUID = testNode.NodeSKUID;

// STEP 3: Create a new test SKU
Logger.WriteLine($"[SKU Association Test] --> Creating new test SKU...");
SKUInfo newTestSku = new SKUInfo();
newTestSku.SKUName = "test-sku-association-" + Guid.NewGuid().ToString().Substring(0, 8);
newTestSku.SKUNumber = "TEST-ASSOC-" + Guid.NewGuid().ToString().Substring(0, 8);
newTestSku.SKUPrice = 1.00m;
newTestSku.SKUEnabled = true;
newTestSku.SKUPublicStatusID = 1;
newTestSku.SKUSiteID = siteID;
newTestSku.SKUProductType = CMS.Ecommerce.SKUProductTypeEnum.Product;

SKUInfo.Provider.Set(newTestSku);
newTestSKUID = newTestSku.SKUID;

Logger.WriteLine($"[SKU Association Test] --> Created new test SKU ID: {newTestSKUID}, Name: '{newTestSku.SKUName}', Number: '{newTestSku.SKUNumber}'");

// STEP 4: Associate the new SKU with the TreeNode
Logger.WriteLine($"[SKU Association Test] --> Associating new SKU (ID: {newTestSKUID}) with TreeNode (ID: {testNodeID})...");
string expectedSKUName = newTestSku.SKUName;
testNode.NodeSKUID = newTestSKUID;
testNode.Update();
testNode.CheckIn();

Logger.WriteLine($"[SKU Association Test] --> Successfully associated new SKU with TreeNode");

// STEP 5: Check if SKUName got blanked and re-set it
Logger.WriteLine($"[SKU Association Test] --> Checking if SKUName was blanked by association...");
var skuAfterAssociation = SKUInfo.Provider.Get(newTestSKUID);
if (skuAfterAssociation != null)
{
    Logger.WriteLine($"[SKU Association Test] --> --> SKUName after association: '{skuAfterAssociation.SKUName}'");

    if (string.IsNullOrWhiteSpace(skuAfterAssociation.SKUName))
    {
        Logger.WriteLine($"[SKU Association Test] --> --> SKUName was BLANKED! Re-setting it to: '{expectedSKUName}'");
        skuAfterAssociation.SKUName = expectedSKUName;
        SKUInfo.Provider.Set(skuAfterAssociation);

        // Verify it stuck this time
        var skuAfterFix = SKUInfo.Provider.Get(newTestSKUID);
        Logger.WriteLine($"[SKU Association Test] --> --> SKUName after re-setting: '{skuAfterFix.SKUName}'");

        // Clear all Kentico caches to ensure UI will see the update
        Logger.WriteLine($"[SKU Association Test] --> --> Clearing Kentico cache...");
        CMS.Helpers.CacheHelper.ClearCache();
        Logger.WriteLine($"[SKU Association Test] --> --> Cache cleared");
    }
    else
    {
        Logger.WriteLine($"[SKU Association Test] --> --> SKUName is still intact!");
    }
}

Correct Answer

Zdeněk Cetkovský answered on February 12, 2026 13:30

Hello,

The behavior you are getting is caused by the fact that the product pages - i.e. Pages that represent a product formed by a Page and a connected SKUInfo - primarily rely on storing the naming (translatable) data in the Page object (TreeNode + Document + coupled table records).

In particular, the fact that you're seeing an empty name in the product edit UI, while there is a value in SKUInfo's SKUName column in the DB is because the UI is getting the data from Page's DocumentSKUName column, which is probably empty.

You can find some more details on the structure at Page database structure - Products

There is also an API example for managing product pages at API examples on product pages management

A short conclusion is that you need to work with page (document) fields as well if you're connecting the two:

...
// Synchronize SKU name with document name in a default culture
node.DocumentSKUName = skuInfo.SKUName;
...

An important note comes in context of multilingual environment: As the SKUInfo is not multilingual and only represents default language data, the value for SKUName (and SKUDescription and SKUShortDescription) field is taken from the default culture version of the Page and its column DocumentSKUName (and DocumentSKUDescription and DocumentSKUShortDescription respectively).

Moreover, if versioning/workflow is turned on, the data being edited in the UI are taken from the latest edited version, stored in appropriate CMS_VersionHistory table record's NodeXML column (which serializes all the fields of Page = TreeNode + Document object/table and SKUInfo. Therefore a manual update approach needs to address all these properly to keep the values in sync.

Looking at your code, the initial change suggested for STEP 4 would be

...
testNode.NodeSKUID = newTestSKUID;
testNode.DocumentSKUName = newTestSKU.SKUName;
...
testNode.Update();
..

You can try to start with this simple change according to your needs and if needed add necessary calls to ensure the proper page version is updated with the SKU data you're connecting to.

Hope this helps! Zdenek

0 votesVote for this answer Unmark Correct answer

Recent Answers


Leif Anderson answered on February 12, 2026 18:56

Thank you so much for the detailed response, Zdeněk!

I was able to successfully update this - just made one minor tweak was the syntax: testNode.SetValue("DocumentSKUName", newTestSKU.SKUName);

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.