private List <CatalogContentBase> GetProductCategories(CatalogContentBase productContent, string language) { var allRelations = _linksRepository.GetRelationsBySource(productContent.ContentLink); var categories = allRelations.OfType <NodeRelation>().ToList(); List <CatalogContentBase> parentCategories = new List <CatalogContentBase>(); try { if (categories.Any()) { foreach (var nodeRelation in categories) { if (nodeRelation.Target != _referenceConverter.GetRootLink()) { CatalogContentBase parentCategory = _contentLoader.Get <CatalogContentBase>(nodeRelation.Target, new LanguageSelector(language)); if (parentCategory != null) { parentCategories.Add(parentCategory); } } } } else if (productContent.ParentLink != null && productContent.ParentLink != _referenceConverter.GetRootLink()) { CatalogContentBase parentCategory = _contentLoader.Get <CatalogContentBase>(productContent.ParentLink, new LanguageSelector(language)); parentCategories.Add(parentCategory); } } catch (Exception ex) { _log.Debug(string.Format("Failed to get categories from product {0}, Code: {1}.", productContent.Name, productContent.ContentLink), ex); } return(parentCategories); }