How to Get Related Products
You can use the Catalog API to get products from a product catalog that are related to a specific product. That is, you can get the products that have a relationship with the specified product.
To get related products
Use the RelatedProducts property on the CatalogItem object to get a dataset that contains the related products for the specified product.
Iterate through the dataset to access the individual products and display them.
Example
This example gets a catalog item specified by the productId. The example then gets a dataset of the products related to the catalog item and iterates through the dataset to access the individual products and writes the DisplayName of the products to the console.
private static void GetRelatedProducts(Catalog catalog, string productId)
{
// Get the product specified by productId.
catalogItem = catalog.GetProduct(productId);
// Get the products related to the specified product.
CatalogRelationshipsDataSet relatedProducts = catalogItem.RelatedProducts;
// Access the products in the dataset and display the name.
foreach (CatalogRelationshipsDataSet.CatalogRelationship relatedProduct in relatedProducts.CatalogRelationships)
{
Console.WriteLine(relatedProduct.DisplayName);
}
}