Try our conversational search powered by Generative AI!

Content Loader is not returning Variants for Product

Vote:
 

This is my method and I am trying to get all variants by using conent loader. But it doesn't work for me. I am on EpiServer (CMS and Commerce) version 11

private IEnumerable GetChildrenAndRelatedEntries(CatalogContentBase catalogContent)
where TEntryContent : EntryContentBase
{
var variantContentItems = this.contentLoader.GetChildren(catalogContent.ContentLink).ToList();

var variantContainer = catalogContent as IVariantContainer;
if (variantContainer != null)
{
variantContentItems.AddRange(this.GetRelatedEntries(variantContainer));
}

return variantContentItems.Where(e => e.IsAvailableInCurrentMarket(this.currentMarket));
}

Any Idea.

#190834
Apr 17, 2018 15:18
Vote:
 

You should use the IRelationRepository instead :) See https://world.episerver.com/documentation/developer-guides/commerce/catalogs/catalog-content/Product-variants/

#190839
Apr 17, 2018 15:45
Vote:
 

IContentLoader.GetChildren on returns the direct children of the parentLink. I.e. if you have more than 1 level of categories then entries in sub-categories are not returned. Check out https://leanpub.com/epicommercerecipes/read_sample, recipe 1.2 

#190840
Apr 17, 2018 15:46
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.