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.

Re: Help Needed: ProductReorderMedia Mutation Not Working as Expected

Solved

Help Needed: ProductReorderMedia Mutation Not Working as Expected

huangcong12
Shopify Partner
12 0 2

Hello,

I use GraphQL to perform various tasks, and usually, everything works as expected.

 

However, when I use the following API to reorder the positions of media images for a product: ProductReorderMedia, it doesn't seem to work as expected.

 

Let me demonstrate:

Initially, the order of the product images is as shown in the picture:

 

huangcong12_3-1717403998242.png

I try to change the order of these 4 images from: 1, 2, 3, 4 to: 4, 3, 2, 1, and wait for the task to complete.

 

huangcong12_4-1717404021645.png

 

 

After the execution, we expect the white cat to be in the first position, the black cat to be in the last position, and the two flower images to swap places.

However, this is not the case; only the images in positions 2 and 4 have swapped places.

huangcong12_5-1717404053539.png

 

I have tried many times, including setting the newPosition values to very high numbers, assigning newPosition to even numbers only, and changing the order of only 2 images at a time, but I have not been able to get the expected result.

 

I am not sure what went wrong and would appreciate any advice on how to solve this issue.

Thank you!

ImgCraft: AI Sharp & Resize - Rescuing Low-Quality Images | LitaCat: Page Watermark - Convey Your Voice
Accepted Solution (1)

Eric-HAN
Shopify Partner
205 26 22

This is an accepted solution.

Hi, there

 

I think the starting index should be 0, not 1 .
In my side ,this is correct.

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee

View solution in original post

Replies 2 (2)

Eric-HAN
Shopify Partner
205 26 22

This is an accepted solution.

Hi, there

 

I think the starting index should be 0, not 1 .
In my side ,this is correct.

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
363518457
Shopify Partner
18 0 2
The same problem, starting from 0, the order of the pictures does not change.
This interface has many problems.
 
{
"id":"gid://shopify/Product/***",
"moves":[
{"id":"gid://shopify/MediaImage/***","newPosition":"0"},
{"id":"gid://shopify/MediaImage/***","newPosition":"1"},
{"id":"gid://shopify/MediaImage/***","newPosition":"2"},
{"id":"gid://shopify/MediaImage/***","newPosition":"3"}
]
}