workflow
Can you please provide me some code for changing a product in the products sample and checking it in and out using C#?
I want to query only published products
I want to check out a product and edit it and then check it in
I want to publish a product
Cheers!
Hi Brian,
You can take a look in the ProductsModule sample.
To query for published products:
var manager = ProductsManager.GetManager();
var products = manager.GetProducts().Where(x => x.Status == ContentLifecycleStatus.Live).ToList();
Thank you Daniel for your response.
Can someone at Telerik please comment on this. I really need to find out how to properly check in and out and publish custom module data like products using C#.
Hello Brian Crosby,
Like Daniel properly pointed out, you'll need to work with Productsmanager. ProductsManager inherits from ContentManagerBase, so basically what you have for a news item:
NewsManager manager = NewsManager.GetManager();
NewsItem item = manager.GetNewsItems()
.Where(t => t.Title == newsTitle)
.Where(t => t.Status == ContentLifecycleStatus.Live)
.Single();
item = manager.GetMaster(item);
// make sure we are working with master
NewsItem temp = manager.CheckOut(item);
// work on a temp
//
temp.Content = newContent;
//
item = manager.CheckIn(temp);
manager.RecompileItemUrls<NewsItem>(item);
manager.Publish(item);
manager.SaveChanges();
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Hello Brian Crosby,
Just a quick follow-up, please find below a sample code for achieveing the same functionality with a products item:
ProductsManager manager = ProductsManager.GetManager();
ProductItem item = manager.GetProducts()
.Where(t => t.Title ==
"title"
)
.Where(t => t.Status == ContentLifecycleStatus.Live)
.Single();
item = manager.Lifecycle.GetMaster(item)
as
ProductItem;
// make sure we are working with master
var temp = manager.Lifecycle.CheckOut(item);
// work on a temp
//
item = manager.Lifecycle.CheckIn(temp)
as
ProductItem;
manager.RecompileItemUrls<ProductItem>(item);
manager.Lifecycle.Publish(item);
manager.SaveChanges();
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>