Try our conversational search powered by Generative AI!

Retrieving assocations by target


If I have an association between product A -> product B, it seems I can only retrieve this association by source. If I ask B for associations (through IAssociationsRepository), it doesn't appear to have any. The UI also reflects this: B has no "Related entries".

The scenario is that I want to show cross links on both product pages... "B is accessory to A" and not only "A has accessory B".

Currently I have to resort to some fugly SQL to make it happen, but I'd much rather have support for this in the API.

Apr 23, 2019 10:45

I never see any APIs that meet your need. I think as Episerver commerce implementation, the assocations are one-direct relations not bi-direct relations, so that is why there are no APIs for this stuff. :)

Apr 24, 2019 9:27

Valid point Johan. This is a place where source/target makes senses (unlike IRelationRepository). We will look into that, however that sounds like a breaking change (adding new methods to interface) so it will not be addressed any time soon

Apr 24, 2019 9:44

Upvoted. I have also a need for this (re-indexing the source on changes of the target). I was a bit surprised that there wasn't support already.

Why would just adding new methods to an interface be a breaking change? I hope that this will be addressed sooner than "not any time soon".

Jun 05, 2019 11:15

The basic definition of breaking change is "you have to fix your code to make it compile" (even though the full concept of breaking changes can be very complicated). Adding a new method to an interface is definitely a breaking change.

Jun 05, 2019 11:18

Ok, I was just thinking this specific interface and that only Episerver would make implementations of it. But you are correct. In general, somebody could have made their own implementation of an interface and that would be broken when new methods are added.

Jun 05, 2019 12:04

Johan Book: As a work-around since associations are not bidirectional, on association create/change event you could check that there is an association in the other direction and create it if needed.

Jun 28, 2019 10:50
* 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.