How can i get all node childes and their childs including childs from CatalogNodeRelation table from Mediachase.Commerce.Catalog.Dto.CatalogNodeDto object?
And theirs entities as additional question.
so for examaple i have node "All products" and as the result i want to get ["Node", "61309895","61311000", "6135198"]
Thanks in advanced.
You can use IRelationRepository, and then GetChildren<NodeRelation>(yourNodeLink) to get the references of the children (nodes and entries).
I could not see your picture so I guess that's what you want. To get the code from ContentReference, you can use ReferenceConverter.
thanks for answer, but I think that convert CatalogNodeDto to ContentReferences and then use ReferenceConverter to get Code is not afficient. But more than that i need to do it in a loop to get chil of child.
My imput has type CatalogNodeDto. I have attach image one more time.
Still can't see it. But if you already have the ChildNodeId, you can use ReferenceConverter to get the contentLink (.GetNodeLink()), and then use that to get the code.
I hope you can see the picture now.
I want to get all nodes (subtree where relation between nodes can be denifined in [CatalogNodeRelation] and [CatalogNode] table) from "All Products" In one function if there are so, without converting CatalogNodeDto to ContentLink back and forth, and the most Important here is to account CatalogNodeRelation table.
so for examaple i have node "All products" and as the result i want to get ["Node", "61309895","61311000", "6135198"] .
Is there good solution for this?
I would actually use the IContentLoader.GetChildren for this. Quan, won't you miss out getting the Node (Catalogs/All Products/Node) if that node's parent is "All Products" with IRelationRepository.GetChildren? From what I can see, the IContentLoader.GetChildren will truly get all the children. Of course it's a bit more expensive loading all that content, but if the example is as small as this and not some bulk thing, it should be negigible.
That's true. The direct child nodes are not returned in IRelationRepository.GetChildren, or in CatalogNodeRelation - but that was before I see the picture. :)
Hm, my above comment only solves the example, really.
Thank you guys for your quick reply.
The problem here is that our structure is that one node can have more than one Parent, and this information is stored in CatalogNodeRelation.
Now with this structure we have a few problems:
int itemsForIndexing = system.StartFindItemsForIndexing(searchSetId, catalogId,
isIncremental, earliestModifiedDate, latestModifiedDate);
To solve this we override event, get all child entities and add them to ApplicationLog table. And in this event we have this CatalogNodeDTO. Before an upgrade to Episerver 11 this event fired for every node separately so we just get entities for current node. But after the upgrade it fires just once. (can it be connected with Episerver upgrade?)
[ServiceConfiguration(typeof(CatalogEventListenerBase), Lifecycle = ServiceInstanceScope.Singleton)]
public class CatalogListener : CatalogEventListenerBase
public override void NodeUpdated(object source, NodeEventArgs args)
var sourceAsCatalogNodeDto = source as Mediachase.Commerce.Catalog.Dto.CatalogNodeDto;
Could you recommend better solution for solving this problems with good performance, since this is one of my biggest interests?
Will code abouve get all nodes accounting CatalogNodeRelation?
var repository = ServiceLocator.Current.GetInstance<IContentLoader>();
var contentLink = referenceConverter.GetContentLink(currentNodeCode);
var nodeCodes = repository.GetChildren<NodeContent>(contentLink).Select(x => x.Code).ToList();