Possible issue with IRelation Repository


Hi there,

I have the following catalog three:

  • Root
    • Catalog
      • Pyjama - category
        • Shorts - category
      • Men - primary category of shorts
        • Shorts - category
          • TheBlueShort

When I call _relationRepository.GetParents<NodeRelation>(reference-to-shorts-category).ToList() I was expecting to get a reference to "Men" category since it's the parent and primary category of "Shorts", but it returns a reference to "Pyjama" which is an additional category. Is that correct? Am I doing anything wrong?

Thank you in advance!

Edited, Dec 02, 2020 17:56

You probably need to use IsPrimary like in the below code snippt

var nodeRelations = _relationRepository.GetParents<NodeEntryRelation>(entryContentReference).ToList();

            var primaryRelation = nodeRelations.FirstOrDefault(x => x.IsPrimary);

            if (primaryRelation != null)
                var thisRelationContentReference = _referenceConverter.GetContentLink(primaryRelation.Parent.ID, CatalogContentType.CatalogNode, primaryRelation.Parent.WorkID);
                var nodeContentBase = _contentLoader.Get<NodeContentBase>(thisRelationContentReference);
                return nodeContentBase.ContentLink;
Feb 27, 2021 14:01
* 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.