Programmatically hiding all products of specific definition
I'm trying to set DisplayOnSite to false on every product of a specific defintion in my solution. I'm a bit of a newbie at .net, so all I can think of is the following code:
var products = Product.Find(x => x.ProductDefinition == pd);
foreach (var product in products)
{
product.DisplayOnSite = false;
product.Save();
}
But it seems to me, like thats a really bad way to do it if you have more than a few products. Is there any better way to set DisplayOnSite to false for every product of a specific definition?
Programmatically hiding all products of specific definition
I'm trying to set DisplayOnSite to false on every product of a specific defintion in my solution. I'm a bit of a newbie at .net, so all I can think of is the following code:
var products = Product.Find(x => x.ProductDefinition == pd);
foreach (var product in products)
{
product.DisplayOnSite = false;
product.Save();
}
But it seems to me, like thats a really bad way to do it if you have more than a few products. Is there any better way to set DisplayOnSite to false for every product of a specific definition?
Hi Søren
You can do it directly in database if you need to do this only once :)
Otherwise use ObjectFactory.Instance.Resolve<IRepository<Product>>() to save a list of products after you've modified them.
is working on a reply...