Just call MetaClass.Load with the ID and check Name on the loaded instance. Would you care to explain why you need this? When working with Content, which is recommended, it seems a bit strange to go into MetaClass details.
I would even prefer to work with DTOs but there is always lack of documentation describing what is what. Content is smth that I would like to avoid.
I need to create a report which consists of a big amount of products and variations and variations of variations. The last ones are custom types. Performance is important. I need to distinguish between standard and custom types. FindItems returns Entry structure which almost fits the report content.
It seems weird to me that it contains MetaClassId without MetaClassName. MetaClassId seems like the only way to get the type.
Loading the Entry type generally has much worse performance than Content, and it was actually obsoleted in the latest release.
And if you load multiple Content in batch (using IContentLoader.GetItems) it will use a DTO to load multiple entries at once and do the same for the MetaObjects containing the Content type/Meta class specific data. And it will do a lot of work processing all this data for you and loading it through the content cache which is far more efficient memory-wise than the DTO:s. So I strongly recommend working with IContentLoader (and IRelationRepository for relations).
Thank you Magnus. It was not obvious at all.
But then how to find the contentLinks list for IContentLoader.GetItems?
I have a structure Catalog - Category - SubCategory - Products or Variations (from old solution) - SKU
I suggest you recurse your category Hierarchy using IContentLoader.GetChildren and find products. Then for each product, use the GetVariants extension method (which uses IRelationRepository) to get a list of ContentReferences that you can then pass to IContentLoader.GetItems. So semi-pseudocode:
foreach (var catalog in IContentLoader.GetChildren<CatalogContent>(ReferenceConverter.GetRootLink))
{
// This part needs to be recursive to handle the category tree
foreach (var category in IContentLoader.GetChildren<NodeContent>(catalog.ContentLink))
{
foreach (var product in IContentLoader.GetChildren<ProductContent>(category.ContentLink))
{
variants = IContentLoader.GetItems<VariationContent>(product.GetVariants());
...
}
}
}
Edit: Don't create giant collections of all products and variants to process them in a later step, write the code to "stream" through the tree and write your report data as you go along. Especially if the catalog is big. Or you risk running out of memory because you're holding reference to practically every content in your database.
Hi
Is that possible to get MetaClassName having entry.MetaClassId? MetaClass is inherited from VariationContent.
Thanks