Hi,
What's version you are using?
If you're using prior to 7.5, you're in the right track. From CatalogRelationDto.NodeEntryRelation table, you can find:
- The rows which has a specific CatalogEntryId, then you can now which Nodes a entry belongs to
- The rows which has a specific CatalogNodeId, then you can now which entries a Node contains.
You may also want to apply a CatalogId when finding.
You also can use ICatalogSystem.GetCatalogEntriesDto which take a catalogNode parameter, for example:
http://world.episerver.com/Documentation/Class-library/?documentId=commerce/7.5/fa8d9748-5d9e-4460-b237-0260f1596ef2
From 7.5, you can use ILinksRepository to get that.
/Q
Thanks for your response. I'm using Commerce 7.5. I think either I'm doing something wrong or I've found a bug here. Here's one line of my code:
CatalogRelationDto relation = CatalogContext.Current.GetCatalogRelationDto(52);
There's a record in the NodeEntryRelation table in the database with CatalogEntryId equal to 52 and CatalogNodeId equal to 71. However, relation.NodeEntryRelation.Count is 0 in this case. Am I using this method incorrectly?
I haven't tried the ILinksRepository yet.
I believe that you need to use the other overload:
http://world.episerver.com/Documentation/Class-library/?documentId=commerce/7.5/c16f749c-1de9-b83e-c74d-d0d0c4152178
Pass the CatalogId and CatalogNodeId/CatalogEntryId here and you will be able to get the NodeEntryRelation, something like this:
//To get the relation of entry. Note that I'm passing CatalogId here. If you want to get all the relation, leave CatalogId = 0
GetCatalogRelationDto(1, 0, 52, string.Empty, new CatalogRelationResponseGroup())
//To get the relation of node
GetCatalogRelationDto(1, 71, 0, string.Empty, new CatalogRelationResponseGroup())
Regards.
/Q
That's exactly what I needed. I didn't realize you could pass 0 for the IDs to get all related items. Thanks so much!
I'm looking for a way to get CatalogNodes related to a specific CatalogEntry and, in reverse, to get CatalogEntries related to a given CatalogNode. I've been looking at the GetCatalogRelationDto method in the Mediachase.Commerce.Catalog.ICatalogSystem interface, but I can't seem to get the information I need from it. When I give it both the Node and the Entry IDs, it will confirm there is indeed a relation between them, but I don't see a way to start with one ID and get other related entities. The first overload which accepts a childEntryId seemed promising, but that appears to return other information, not related to CatalogNodes. Can anyone point me in the right direction?