Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Product images disappear sometimes after bulk update operation

Product images disappear sometimes after bulk update operation

Iceshop
Shopify Partner
2 0 0

We use GraphQL Admin API for updating products in bulk, using productUpdate and bulkOperationRunMutation.

Normally all works fine, but sometimes images disappear for some products after such update, with no error message.
It happens when we send images ids after changing their order. So no new images urls, just ids of existing images in new order.
Bulk operation example:

mutation {
            bulkOperationRunMutation(
            mutation: "mutation call($input: ProductInput!) { productUpdate(input: $input) { product {id} userErrors { message field } } }",
            stagedUploadPath: "tmp/61844521178/bulk/f739b254-0406-4555-af4a-c65b8810323c/shopify_update_products.json") {
                bulkOperation {
                    id
                    url
                    status
                }
                userErrors {
                    message
                    field
                }
            }
         }

shopify_update_products.json contains rows like these:

{"input":{"id":"gid:\/\/shopify\/Product\/7687249035482","images":[{"id":"gid:\/\/shopify\/ProductImage\/40047562522842"},{"id":"gid:\/\/shopify\/ProductImage\/40057898893530"},{"id":"gid:\/\/shopify\/ProductImage\/40057898827994"},{"id":"gid:\/\/shopify\/ProductImage\/40047562588378"},{"id":"gid:\/\/shopify\/ProductImage\/40047562555610"},{"id":"gid:\/\/shopify\/ProductImage\/40047562621146"},{"id":"gid:\/\/shopify\/ProductImage\/40057898795226"},{"id":"gid:\/\/shopify\/ProductImage\/40047562653914"},{"id":"gid:\/\/shopify\/ProductImage\/40057898860762"},{"id":"gid:\/\/shopify\/ProductImage\/40057898762458"}]}}
{"input":{"id":"gid:\/\/shopify\/Product\/7687250215130","images":[{"id":"gid:\/\/shopify\/ProductImage\/40463199404250"},{"id":"gid:\/\/shopify\/ProductImage\/40463199437018"},{"id":"gid:\/\/shopify\/ProductImage\/40463199469786"},{"id":"gid:\/\/shopify\/ProductImage\/40463199502554"},{"id":"gid:\/\/shopify\/ProductImage\/40463199535322"},{"id":"gid:\/\/shopify\/ProductImage\/40463212871898"},{"id":"gid:\/\/shopify\/ProductImage\/40463212904666"},{"id":"gid:\/\/shopify\/ProductImage\/40463212937434"},{"id":"gid:\/\/shopify\/ProductImage\/40463212970202"},{"id":"gid:\/\/shopify\/ProductImage\/40463213002970"},{"id":"gid:\/\/shopify\/ProductImage\/40463534588122"},{"id":"gid:\/\/shopify\/ProductImage\/40463534620890"},{"id":"gid:\/\/shopify\/ProductImage\/40463534653658"},{"id":"gid:\/\/shopify\/ProductImage\/40463534686426"},{"id":"gid:\/\/shopify\/ProductImage\/40463534719194"},{"id":"gid:\/\/shopify\/ProductImage\/40463779037402"},{"id":"gid:\/\/shopify\/ProductImage\/40463779070170"},{"id":"gid:\/\/shopify\/ProductImage\/40463779102938"},{"id":"gid:\/\/shopify\/ProductImage\/40463779135706"},{"id":"gid:\/\/shopify\/ProductImage\/40463779168474"}]}}
{"input":{"id":"gid:\/\/shopify\/Product\/7687250641114","images":[{"id":"gid:\/\/shopify\/ProductImage\/40237366051034"},{"id":"gid:\/\/shopify\/ProductImage\/40237366083802"},{"id":"gid:\/\/shopify\/ProductImage\/40237366116570"},{"id":"gid:\/\/shopify\/ProductImage\/40237366149338"},{"id":"gid:\/\/shopify\/ProductImage\/40237366182106"},{"id":"gid:\/\/shopify\/ProductImage\/40242900467930"},{"id":"gid:\/\/shopify\/ProductImage\/40242900500698"},{"id":"gid:\/\/shopify\/ProductImage\/40242900533466"},{"id":"gid:\/\/shopify\/ProductImage\/40242900566234"},{"id":"gid:\/\/shopify\/ProductImage\/40242900599002"},{"id":"gid:\/\/shopify\/ProductImage\/40242968494298"},{"id":"gid:\/\/shopify\/ProductImage\/40242968527066"},{"id":"gid:\/\/shopify\/ProductImage\/40242968559834"},{"id":"gid:\/\/shopify\/ProductImage\/40242968592602"},{"id":"gid:\/\/shopify\/ProductImage\/40242968625370"},{"id":"gid:\/\/shopify\/ProductImage\/40246756671706"},{"id":"gid:\/\/shopify\/ProductImage\/40246756704474"}]}}

The results of the bulk operation is successful:

 

 

{"data":{"productUpdate":{"product":{"id":"gid:\/\/shopify\/Product\/7687249035482"},"userErrors":[]}},"__lineNumber":0}
{"data":{"productUpdate":{"product":{"id":"gid:\/\/shopify\/Product\/7687250215130"},"userErrors":[]}},"__lineNumber":1}
{"data":{"productUpdate":{"product":{"id":"gid:\/\/shopify\/Product\/7687250641114"},"userErrors":[]}},"__lineNumber":2}

But actually some products may lose their images.
Usually it doesn't happen, but sometimes it happens with some of the updated products.

 

What could be the cause?

 

Replies 3 (3)

Liam
Community Manager
3108 344 909

Hi Iceshop - this does sound unusual, I've reached out to our internal team to see what might be causing this. 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Liam
Community Manager
3108 344 909

Hi again - our API support have advised using the task-specific productReorderMedia mutation instead. This mutation runs as an asynchronous job (kind of like a self contained bulk operation) and is designed just for re-ordering media so should be most reliable for the task. Would this work for your use-case?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Iceshop
Shopify Partner
2 0 0

Hi Liam,

 

Thanks for the suggestion. We will check if productReorderMedia helps.