Image path updating using API at SKU level

Image path updating using API at SKU level

naveedshahidecs
Shopify Partner
2 0 0

Hi i need to update product Variant images paths via API from my ERP integrations. please let me know if it is possible to attach product image links at variants level. any help in this regards will help us. thanks

 

naveedshahidecs_0-1658407016200.png

 

Reply 1 (1)

Philip_Zhavrid
Shopify Partner
16 2 62

Hi @naveedshahidecs 

Using Shopify API you can add an existing image to an existing product variant. Is that what you are looking for? 
If yes, I think you can use this  https://shopify.dev/api/admin-rest/2022-01/resources/product-variant#put-variants-variant-id 

use Shopify\Rest\Admin2022_01\Variant;
use Shopify\Utils;
$this->test_session = Utils::loadCurrentSession(
$requestHeaders,
$requestCookies,
$isOnline
);
$variant = new Variant($this->test_session);
$variant->id = 808950810;
$variant->image_id = 562641783;
$variant->save(
true, // Update Object
);

If you are looking for something else, then please let me know and I'll to help you.