IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
Up until Sitefinity CMS 6.0, Ecommerce module did not track who the owner of the product is. Starting with 6.0 it now tracks the owner of any newly created product. Since we never had owner information before, it is hard to guess the owner of the product. If an upgrade is run under a certain user (i.e. you logged in as admin and then you run the upgrade) the current user (admin) is picked as the owner of the product automatically. If you did not run the upgrade logged in as the desired user and want to change the owner of the product later on, use the script below:
private
void
ChangeOwnerOfProducts()
{
Guid currentUserId = Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserId();
using
(var catalogManager = CatalogManager.GetManager())
var products = catalogManager.GetProducts().Where(p => p.Status == Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master && p.OriginalOwner ==
null
);
foreach
(Product masterProduct
in
products)
productLive.Status = Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master;
if
(currentUserId != Guid.Empty)
masterProduct.Owner = currentUserId;
masterProduct.OriginalOwner = currentUserId;
}
catalogManager.SaveChanges();
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important