Sitecore Commerce 9: How to Get Related Products for Sellableitem

Andrei Paliakou on December 14, 2019

Sitecore Commerce 9 has a possibility to link relative SellableItems to SellableItem OOTB. All these related SellableItems will be rendered in Related Products component on Storefront site. If you need to configure a list of related products, all you need to navigate to SellableItem in BizFx site and link them in Related Products section.

Technically, when you link any related SellableItem to SellableItem as a related product, Sitecore Commerce Engine creates a new RelatedProduct list per each SellableItem, for example List-relatedproduct-6042102-ByDate, where 6042102 is a product id. All this data Commerce Engine stores in [SitecoreCommerce9_SharedEnvironments].[dbo].[CatalogLists] table in SQL.

Sitecore provides Postman request Lists - RelatedProduct Relationships to retrieve related products by list:

{{ServiceHost}}/{{ShopsApi}}/GetList(id='RelatedProduct-6042102',type='Sitecore.Commerce.Plugin.Catalog.SellableItem, Sitecore.Commerce.Plugin.Catalog',skip=0,take=100)?$expand=Items

Everything was good till Sitecore Commerce 9 Update-3 was rolled out. When I tried to retrieve related products with the Postman request above, I didn’t get a list of related products. It was a surprise for me and I started to investigate this issue.

During my investigation I found that Sitecore changed list name for related products from relatedproduct to relatedsellableitemtosellableitem.

[SitecoreCommerce9_SharedEnvironments].[dbo].[CatalogLists] table in SQL starts form Update-3 version looks like:

Then I took a look at Postman request and found that there was an old list name. Instead of request url above should be:

{{ServiceHost}}/{{ShopsApi}}/GetList(id='relatedsellableitemtosellableitem-6042102',type='Sitecore.Commerce.Plugin.Catalog.SellableItem, Sitecore.Commerce.Plugin.Catalog',skip=0,take=100)?$expand=Items

After that I was able to retrieve related product in Postman:

Hope it helps someone who encounters the same issue!