Skip to main content
Anchor to collectionReorderProducts

collectionReorderProducts

mutation

Requires write_products access scope. Also: The user must have a permission to reorder products within a collection.

Asynchronously reorders the products of a manually sorted collection. Instead of returning an updated collection, this mutation returns a job, which should be polled. The Collection.sortOrder must be MANUAL.

Positions are zero-based indexes in the collection's list of products. Products that the request doesn't list keep their relative order, and the reorder leaves no gaps. The description of each argument that reorders products says how it places them.

•ID!
required

The ID of the collection on which to reorder products.

•[MoveInput!]!
required

A list of moves to perform, applied one at a time in the order given. Provide only the products that move; don't send the whole list.

  • newPosition is a zero-based index in the list as it is when the move applies, after all earlier moves in the list.
  • newPosition values don't need to be unique. A value greater than or equal to the number of products moves the product to the end.
  • Products that aren't in moves keep their relative order, aside from the displacement that the moves cause.

Example:

  • Initial order: [A, B, C, D, E] (indexes 0 to 4)
  • Moves, applied in order: E to newPosition: 1, then C to newPosition: 4
  • Result: [A, E, B, D, C]

Up to 250 moves are supported.

Show input fields

Was this section helpful?

Anchor to CollectionReorderProductsPayload returnsCollectionReorderProductsPayload returns

•Job

The asynchronous job reordering the products.

Show fields
•[CollectionReorderProductsUserError!]!
non-null

The list of errors that occurred from executing the mutation.

Show fields

Was this section helpful?