Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
metaClass.DeleteField(metaFieldName) should do the work for you. So basically
MetaDataContext metaDataContext = CatalogContext.MetaDataContext;
MetaClass metaClass = Mediachase.MetaDataPlus.Configurator.MetaClass.Load(metaDataContext, "metaclassname");
metaClass.DeleteField("metafieldname");
I am not able to delete MetaField programmatically, because said MetaField are linked to MetaClass/MetaClasses and therefore cannot be deleted. Below code works after removing the MetaField link to MetaClass/MetaClasses manually within the Commerce Manager, but I want to automate that process.
I have read threads regarding the topic on this Forum. They all seem to be linking to another thread explaining this. That thread seems to be no longer available (https://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=142928).
MetaDataContext metaDataContext = CatalogContext.MetaDataContext; MetaClass metaClass = Mediachase.MetaDataPlus.Configurator.MetaClass.Load(metaDataContext, "metaclassname"); IEnumerable<MetaField> allMetaFields = metaClass.GetAllMetaFields(); foreach (MetaField metaField in allMetaFields) { if (metaField.Name.Equals("metafieldname")) { MetaField.Delete(metaDataContext, metaField.Id); } }
How would I go about checking for MetaField link/links to MetaClass/MetaClassses programmatically, and then delete the link, so that above code would work?