-
-
Notifications
You must be signed in to change notification settings - Fork 313
Product Images
Joshua Harms edited this page Jan 21, 2025
·
2 revisions
Warning
All public Shopify apps (i.e. those published on the Shopify App Store) are required to switch over to using the GraphQL product API by February 1st. All custom apps are required to switch by April 1st. Go here for a migration guide on using ShopifySharp's GraphService to query and mutate Shopify's GraphQL API.
Product Images represent the various different images for a product. All product images are tied to an owner product, and therefore you'll need to pass that product's id to each product image method.
var service = new ProductImageService(myShopifyUrl, shopAccessToken);
var image = await service.CreateAsync(productId, new ProductImage()
{
Metafields = new List<MetaField>()
{
new MetaField()
{
Key = "alt",
Value = "new alt tag content",
ValueType = "string",
Namespace = "tags"
}
},
Src = "https://placekitten.com/200/300"
});
var service = new ProductImageService(myShopifyUrl, shopAccessToken);
var image = await service.GetAsync(productId, imageId);
var service = new ProductImageService(myShopifyUrl, shopAccessToken);
var count = await service.CountAsync(productId);
var service = new ProductImageService(myShopifyUrl, shopAccessToken);
var images = await service.ListAsync(productId);
var service = new ProductImageService(myShopifyUrl, shopAccessToken);
var image = await service.UpdateAsync(productId, imageId, new Image()
{
Position = 2
});
var service = new ProductImageService(myShopifyUrl, shopAccessToken);
await service.DeleteAsync(productId, imageId);