Api : Add image to variant when adding a new product

Mammouth
Tourist
15 0 2

using the shopify api,

 

i can add product variant like this $product->variants = [ [ "option1" => "color" "price" => "1.23", "sku" => "abc" ] ]; $shopify->Product->post($p);

 

But how can i add image to the same variant, i tried with

"image" => $p->image

"images" => $p->image

"imageSrc" => $p->image

"attachment" => base64_encode($r)

 

but no one is working

 

Thanks

Reply 1 (1)

Mammouth
Tourist
15 0 2

Seem that the only way is to add the image to a product then get it's imageId and update the variant image_id.