No longer able to save existing SKUs or create new SKUs

Andy Bochmann asked on August 10, 2019 01:41

Hello,

After updating to Kentico 12 SP (at least it seems that's when it started), I'm no longer able to create new SKUs or update existing SKUs. The message I get is An error occurred when saving data. Please see event log for more details.

After checking the Event Log, I can see that the error is:

Query: 
UPDATE COM_SKU SET [SKULastModified] = @SKULastModified, [SKUBrandID] = @SKUBrandID, [SKUCollectionID] = @SKUCollectionID
WHERE [SKUID] = @SKUID

Caused exception: 
The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_COM_SKU_COM_Brand". The conflict occurred in database "Kentico", table "dbo.COM_Brand", column 'BrandID'.
The statement has been terminated.

I get the same Exception for the INSERT statement, when adding a new SKU.

The next thing I've tried was temporarily removing the constraint for Brands, but then I get the same exception for Collections:

Caused exception: 
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_COM_SKU_SKUCollectionID_COM_Collection". The conflict occurred in database "Kentico", table "dbo.COM_Collection", column 'CollectionID'.
The statement has been terminated.

I'm not even using Brands or Collections, but even when creating and selecting a Brand, I still get the same exception.

I'm currently running the hotfix version 34 and the issue happens on my local dev machine as well as our test app in Azure.

Thanks, Andy

Recent Answers


Andy Bochmann answered on August 10, 2019 01:57

A few more observations:

  • I noticed that [SKUBrandID] and [SKUCollectionID] get saved with the value 0 instead of NULL
  • After selecting an existing Brand or Collection, it still saves the value 0. It does not save the SKU with the selected BrandId or CollectionId. Same happens with other fields, like Manufacturer. However, Tax class gets saved correctly.

Seems like something inside Kentico doesn't assign the correct values when saving.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on August 12, 2019 14:44

Just wondering... have you customized e-commerce functionality? If not, you should probably reach support directly

0 votesVote for this answer Mark as a Correct answer

Andy Bochmann answered on August 12, 2019 17:18

I've only made customizations, that shouldn't cause this error, for example I've added a custom shipping prodiver and a custom price calculation module.

I did however also add custom fields to the SKU class, but made those changes only though the Modules application and didn't modify the database directly. I've added the same custom fields to the Dancing Goat application, which doesn't show this problem.

Ok, I will try to reach Kentico support directly.

0 votesVote for this answer Mark as a Correct answer

Andy Bochmann answered on August 12, 2019 17:29

I also just noticed that some fields of the UI are messed up. A lot of fields appear somewhere else, for example, Brand and Manufacturer appear at the top, but also under Custom Properties. Same with most other fields. I'm not sure why they appear multiple times on the Content tab. I'll try to modify the UI and see if that solves the problem.

0 votesVote for this answer Mark as a Correct answer

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