Hi
when entering a product variant, that is not default variant - can I get the image of the Default Variant - eg. using the API?
/Hans
Hi
when entering a product variant, that is not default variant - can I get the image of the Default Variant - eg. using the API?
/Hans
Frontend or backend - or what is your context?
You can always get the product by id from productservice, and on the master you can see the default variant ID - and then get that variant from the product service as well and then locate the image you need.
Hi
on a product page, I have tried this
@{
string langId=GetString("Ecom:Product.LanguageID");
string productidForVariantSearch=@GetString("Ecom:Product.ID");
string defaultVariantId=@GetString("Ecom:Product.DefaultVariantComboID");
var defaultProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(defaultVariantId, productidForVariantSearch, langId);
string testObject=defaultProduct.Id
}
But declaring the testObject string gives an error saying the object does not exist. So the ProductService does not return a product object as I would expect. What am I doing wrong?
/Hans
Could it be this:
string productidForVariantSearch=@GetString("Ecom:Product.ID");
string defaultVariantId=@GetString("Ecom:Product.DefaultVariantComboID");
You don't need the @ symbol as you're not outputting anything.
Imar
Hi
Thank you for your reply
Unfortunately, that does not make any difference. GIves the same result.
/Hans
Ok, got the PorductService working - but how can I get the Primary Image for the product?
We are using the asset categories for Images https://www.screencast.com/t/vuslOT62uD
But the product class does not have a property for primary image or asset categories https://doc.dynamicweb.com/api/html/47e46310-6920-7861-849f-e8ac081269b0.htm
there are some obsolete methods "GetProductFieldValue" and "GetPropertyValue" - but these are marked as obsolete
Can´t really figure out where to go from here to get the primary image, based on the produc class?
/Hans
You must be logged in to post in the forum