Get all product images

Hi, is there a way to get all product images?

Litium version: 7

You got an example in ProductItemViewModelBuilder.cs

productModel.GetValue<IList<Guid>>(SystemFieldDefinitionConstants.Images).MapTo<IList<ImageModel>>()

or you can do something like this:

 List<ImageModel> images = baseProduct.Fields.GetValue<IList<Guid>>(SystemFieldDefinitionConstants.Images)?.MapTo<IList<ImageModel>>();

foreach (var variant in variants)
{
    images.AddRange(variant.Fields.GetValue<IList<Guid>>(SystemFieldDefinitionConstants.Images)?.MapTo<IList<ImageModel>>());
}
1 Like

Great, thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.