Working with Meta Class from Commerce Connect v10

  • Updated

In Commerce Connect v10, Metadata Plus is introduced. This article demonstrates performing CRUD actions with the new MetaClass class (in the Mediachase.MetaDataPlus.Configurator assembly) in Catalog and Order systems. 

//Create
var metaDataContext = CatalogContext.MetaDataContext;
var metaClassName = "Something";
var tableName = String.Format("{0}{1}{2}", parentMetaClass.Name, "Ex_", metaClassName);
var parentMetaClass = MetaClass.Load(metaDataContext, "CatalogEntry");

MetaClass.Create(metaDataContext, metaClassName, "friendly name",tableName, parentMetaClass.Id, false, "description");

//Get
MetaClass.Load(CatalogContext.MetaDataContext, "metaClassName")

//Update: just set the meta class properties.
metaClass.Name += "-updated";
metaClass.MetaFields.Add(...);

//Delete
MetaClass.Delete(CatalogContext.MetaDataContext, id);