Hello,
This is the solution we would recommend. It is not a good practice to update database columns directly in, as they may be cached by Kentico, leading to data inconsistency. Using API is the best way.
If this is not what you are looking for, let us know more details about what are you trying to do achieve and we will try to assist further.
On a side note, this section of the code:
// Create new order status user object
OrderStatusUserInfo newUserStatus = new OrderStatusUserInfo();
// Set the properties
newUserStatus.OrderID = order.OrderID;
newUserStatus.ChangedByUserID = CMSContext.CurrentUser.UserID;
newUserStatus.FromStatusID = order.OrderStatusID;
newUserStatus.ToStatusID = nextOrderStatus.StatusID;
newUserStatus.Date = DateTime.Now;
// Set the order status user
OrderStatusUserInfoProvider.SetOrderStatusUserInfo(newUserStatus);
Is not necessary if you do not need to set specific ChangedByUser information and is in the API examples for demonstration purposes. CurrentUser will always be shown in the Order Status History.
Regards,
Josef Dvorak