Hello everybody,
I am new to sitefinity development and I am not sure if I am on correct path with solving my problem.
I have a bunch of Partners. They are represented as dynamic modules in my Sitefinity CMS. My task is to switch the Default Image with new image provided by my design department.
Can I call
dynamicModuleManager.SaveChanges();
dynamicModuleManager.Lifecycle.Publish(partner);
dynamicModuleManager.SaveChanges();
in a loop so many times(cca 500)?
I have written code as follows:
var providerName = "dynamicProvider5";
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
Type myCustomPartnerType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.BTCPartners.MyCustomPartnerType ");
var myCollection = dynamicModuleManager.GetDataItems(bTCPartnerType).Where(d => d.Status == ContentLifecycleStatus.Master);
foreach (var partner in myCollection)
{
Image emptyHeroImage = partner.GetRelatedItems< Image >("HeroImage").Where(d => d.Status == ContentLifecycleStatus.Master && d.GetValue("Title") == "DefaultImage").FirstOrDefault();
if (emptyHeroImage != null)
{
Image newImage = GetImage(partner.GetString("PartnerID"));
if (newImage!=null)
{
partner.DeleteRelation(emptyHeroImage , "HeroImage");
partner.CreateRelation(newImage, "HeroImage");
dynamicModuleManager.SaveChanges();
dynamicModuleManager.Lifecycle.Publish(partner);
dynamicModuleManager.SaveChanges();
}
}
}
For anybody who might be interested. I got answer from support and they include this link. I think i can share the link.
knowledgebase.progress.com/.../how-to-republish-all-documents-at-once-using-the-api