Anchor to section titled 'undefined'

productReorderImages
mutation
deprecated

Requires write_products access scope. Also: The user must have a permission to reorder product images.

Asynchronously reorders a set of images for a given product. Use productReorderMedia instead.


Anchor to id
id
required

The ID of the product on which to reorder images.

A list of moves to perform which will be evaluated in order.


Was this section helpful?

The asynchronous job which reorders the images.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) {
  productReorderImages(id: $id, moves: $moves) {
    job {
      id
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) { productReorderImages(id: $id, moves: $moves) { job { id } } }",
 "variables": {
    "id": "gid://shopify/Product/108828309",
    "moves": [
      {
        "id": "gid://shopify/ProductImage/183532652",
        "newPosition": "2"
      },
      {
        "id": "gid://shopify/ProductImage/731367280",
        "newPosition": "3"
      }
    ]
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) {
    productReorderImages(id: $id, moves: $moves) {
      job {
        id
      }
    }
  }`,
  {
    variables: {
      "id": "gid://shopify/Product/108828309",
      "moves": [
        {
          "id": "gid://shopify/ProductImage/183532652",
          "newPosition": "2"
        },
        {
          "id": "gid://shopify/ProductImage/731367280",
          "newPosition": "3"
        }
      ]
    },
  },
);

const data = await response.json();
session = ShopifyAPI::Auth::Session.new(
  shop: "your-development-store.myshopify.com",
  access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
  session: session
)

query = <<~QUERY
  mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) {
    productReorderImages(id: $id, moves: $moves) {
      job {
        id
      }
    }
  }
QUERY

variables = {
  "id": "gid://shopify/Product/108828309",
  "moves": [{"id"=>"gid://shopify/ProductImage/183532652", "newPosition"=>"2"}, {"id"=>"gid://shopify/ProductImage/731367280", "newPosition"=>"3"}]
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) {
      productReorderImages(id: $id, moves: $moves) {
        job {
          id
        }
      }
    }`,
    "variables": {
      "id": "gid://shopify/Product/108828309",
      "moves": [
        {
          "id": "gid://shopify/ProductImage/183532652",
          "newPosition": "2"
        },
        {
          "id": "gid://shopify/ProductImage/731367280",
          "newPosition": "3"
        }
      ]
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation productReorderImages($id: ID!, $moves: [MoveInput!]!) {
    productReorderImages(id: $id, moves: $moves) {
      job {
        id
      }
    }
  }
QUERY;

$variables = [
  "id" => "gid://shopify/Product/108828309",
  "moves" => [{"id"=>"gid://shopify/ProductImage/183532652", "newPosition"=>"2"}, {"id"=>"gid://shopify/ProductImage/731367280", "newPosition"=>"3"}],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "id": "gid://shopify/Product/108828309",
  "moves": [
    {
      "id": "gid://shopify/ProductImage/183532652",
      "newPosition": "2"
    },
    {
      "id": "gid://shopify/ProductImage/731367280",
      "newPosition": "3"
    }
  ]
}
Hide code
Response
JSON
{
  "productReorderImages": {
    "job": {
      "id": "gid://shopify/Job/9b108d8e-4317-40a9-9570-17682a8891d5"
    }
  }
}