Updating variant image with image_id?

marlexladagmarlexladag Member Posts: 8

How can we attach existing image to a variant using eCom API?

5 comments

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 991 moderator

    Hi @marlexladag ,

    Thank you for contacting us.

    You can do this by updating the variant and attach the image, please check https://developers.lightspeedhq.com/ecom/endpoints/variant/#put-update-a-variant for more information.


  • Ron23Ron23 Member Posts: 4

    i also encounter this as a problem. Of course i already checked the link you give here. For me it does not explain how to succesfully attach the image. All the other information are succesfully updated, but not the image. So I started a discussion about this elsewhere. But can you provide a working example with Json body how to succesfully upload an image and link it to a variant or product?

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 991 moderator

    Hi @Ron23,

    Thank you for contacting us.

    You can use something like this to convert your image to a base64 attachment, https://stackoverflow.com/questions/3967515/how-to-convert-an-image-to-base64-encoding or an online tool like: https://www.base64-image.de/

  • OnlineDistributeurOnlineDistributeur Member Posts: 22

    Hello Lucien, we have had an issue with uploading images for variants and getting duplicates on the product.

    When we upload images to the Variants endpoint as described in the documentation, base64 encoded, the image gets automatically added to the ProductImages endpoint/group and appears on the Product Level as well as the Variant level.

    Since we have many variant images that are equal (many sizes for one color and only one picture per color) the result is that the product contains a lot of dupcliate images.

    How can we avoid the variant images to be added as duplicates on the product?

    For example - if there was a way of setting the variant image by referring to an existing image id (eg. productImage id) it would solve it.

    ie.

    { "variant" : { "image" : <productImageID> } }

    Or if the variant images were not automically added as product images it would also help.

    can you please advise on what todo here?

    Kind regards

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 991 moderator

    Hi @OnlineDistributeur,

    Thank you for your explanation.

    I don't think this is possible. I'm going to log this, so our devs are aware of it. I also talked to your colleague Tim about it.

Sign In or Register to comment.