Change the product image when select a product variant

Luis Antonio Picado Fernández asked on June 7, 2017 17:42

I've been searching and can't seem to find the way to change the product image on the onChange/onSelect of the product variant. The site I am working on needs to have multiple variants and one image asocciated to those specific variant. Then on the site you can select a variant and I want to change the image.

Is this supported in Kentico 9?

Anyway I can do that?

Recent Answers

Prashant Verma answered on June 8, 2017 11:14

Hi Luis,

No its the out of box feature.

If you really want to implement the image variant of the product you must need to write a custom control inspired by the ShoppingCartItemSelector.ascx, that will render the options using your custom code and need to pulling data about variants using API and change the original product image on some event listener's, that will outputting an exact markup you need.

Product API

Product Variant API

Informative:: In Kentico 10.0.0 release you have the image variant feature.


Happy to help you

2 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on June 8, 2017 16:32

If you wish some other options to accomplish this are:

  1. If you add Attachment images with the same variant SKU Name or ID or what not, you set the image source using a macro perhaps (would need to set a macro parameter of the current Variant, which may require a custom control) or through client side javascript via an array of all the image attachments, and a check of what drop down value is set.
  2. You could create a custom module interface to link Variants to Images and do a lookup on that, but again you'll need to know what the current variant is.

I would check kentico documentation on adding parameters to the macro engine, it should be this function.

2 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.