Hi Im using Variants for the first time in DW 8. can anyone advise the best way to do this using the DW API's available methods:
Parameters:
VariantOptionId = "VO1"
LanguageId = "LANG1"
ProductName = "AProductName"
VariantGroup selectedVariantGroup = VariantGroup.GetGroupByOptionId(VariantOptionId );
List<Product> products = Product.GetProductsByVariantGroup(selectedVariantGroup).Where(n => n.LanguageID == LanguageId && n.Name == ProductName).ToList();
products = products.? now filter the product list for products with the variant option = VariantOptionId
Alternatively:
ProductCollection productsByNameAndLanguage = Product.GetProductsByNameAndLanguage(ProductName, LanguageId);
Product masterProduct = productsByNameAndLanguage.Select(n => n).Where(m => m.IsVariantMaster).FirstOrDefault();
ProductCollection ProductsAndVariantsByProduct = Product.GetProductsAndVariantsByProduct(masterProduct);
now filter the product list for products with the variant option = VariantOptionId ??
foreach (var p in ProductsAndVariantsByProduct.Where(n=>!n.IsVariantMaster))
{
VariantCombinationCollection productCombinations = p.VariantCombinations;
foreach(var comb in productCombinations)
{
comb.VariantOptions is always null ??
}
}
Looking at values passed from the api it seems each product has all the Variants from the system, and not related to the conserned product
any help appreciated.