My store is using 2024-01.
I have created a script to create images using as well as a script to create products. I cannot get the right combination to associate images with products.
productAppend__Images: Deprecated in 2024-01. Points to productCreateMedia.
productCreateMedia “Creates media for a product.”
productUpdateMedia “Updates media for a product.”
In my case, the media already exists and does not need to be “created”. It exists. It also may not need to be “updated” since I don’t need to change anything about the image itself.
It needs to be associated with a product. Here is a log of an attempt with “productUpdateMedia” which shows “Media associated successfully”
Questions:
-
Is the media successfully associated with the product such that I’m missing something basic to be able to view the image in the product listing?
-
What is the correct mutation to use for this case: productCreateMedia, productUpdateMedia, other?
-
Any tips for resolving this issue?
Result JSON structure:
{
“data”: {
“productCreate”: {
“product”: {
“id”: “gid://shopify/Product/9382772670761”
},
“userErrors”:
}
},
“__lineNumber”: 0
}
Associating media for product: gid://shopify/Product/9382772670761, handle: test_the-outsiders_–american-history-hit–test-episode—1
Media association result for product gid://shopify/Product/9382772670761: {
“data”: {
“productUpdateMedia”: {
“media”: [
{
“id”: “gid://shopify/MediaImage/38315833393449”,
“alt”: “Product image”,
“mediaContentType”: “IMAGE”
}
],
“mediaUserErrors”: ,
“product”: {
“id”: “gid://shopify/Product/9382772670761”
}
}
},
“extensions”: {
“cost”: {
“requestedQueryCost”: 10,
“actualQueryCost”: 10,
“throttleStatus”: {
“maximumAvailable”: 2000.0,
“currentlyAvailable”: 1990,
“restoreRate”: 100.0
}
}
}
}
Media associated successfully
Media check result: {
“data”: {
“node”: {
“id”: “gid://shopify/MediaImage/38315833393449”,
“image”: {
“url”: "…-e335-439b-bebe-14f49906836c.jpg?v=1714877019 ",
“altText”: “Product image”
}
}
},
“extensions”: {
“cost”: {
“requestedQueryCost”: 2,
“actualQueryCost”: 2,
“throttleStatus”: {
“maximumAvailable”: 2000.0,
“currentlyAvailable”: 1998,
“restoreRate”: 100.0
}
}
}
}
Image URL:…-e335-439b-bebe-14f49906836c.jpg?v=1714877019
Alt Text: Product image
Product details after media association: {
“data”: {
“product”: {
“id”: “gid://shopify/Product/9382772670761”,
“title”: “Test_The Outsiders_”,
“status”: “ACTIVE”,
“images”: {
“edges”:
}
}
},
“extensions”: {
“cost”: {
“requestedQueryCost”: 7,
“actualQueryCost”: 3,
“throttleStatus”: {
“maximumAvailable”: 2000.0,
“currentlyAvailable”: 1997,
“restoreRate”: 100.0
}
}
}
}