London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
Hi Pham,
I had a similar use case for one of our projects, I went about creating a bidirectional association. I associate the part to the product (Ex: Part1 is associated to Product1) and I created another association between product and part (Ex: Product1 is associated to Part1). I also segmented the associations into 2 different association groups.
Below is a quick sample of what you can do (will need some refinement):
associations.Add(new Association
{
Group = new AssociationGroup
{
Name = "ProductAssociation",
Description = "The product associated to the part",
SortOrder = 100
},
SortOrder = 100,
Source = partRef,
Target = variant.GetParentProducts().FirstOrDefault(),
Type = new AssociationType
{
Id = AssociationType.DefaultTypeId,
Description = string.Empty
}
});
associations.Add(new Association
{
Group = new AssociationGroup
{
Name = "PartAssociation",
Description = "The part associated to the product",
SortOrder = 100
},
SortOrder = 100,
Source = variant.GetParentProducts().FirstOrDefault(),
Target = partRef,
Type = new AssociationType
{
Id = AssociationType.DefaultTypeId,
Description = string.Empty
}
});
_associationRepository.Value.UpdateAssociations(associations);
And below is how it would look like under realted entries:
Hi,
As i understand we only get related entries for an entry. But I want to do the opposite.
Can from Target i want get all Source related entries
For examle:
Product 1 have related entries product1(part1, part2, part3, par4)
Product 2 have related entries product1(part1, part2)
Product 3 have related entries product1(part3, part4)
Product 4 have related entries product1(part1, part4)
=> i want from part1 get all Product1, Product2, Product4
https://world.episerver.com/documentation/developer-guides/commerce/catalogs/catalog-content/Related-entries/
Regards,
T