Collect

The Collect resource connects a product to a custom collection.

Collect

Collects are meant for managing the relationship between products and custom collections. For every product in a custom collection there is a collect that tracks the ID of both the product and the custom collection. A product can be in more than one collection, and will have a collect connecting it to each collection. Unlike many Shopify resources, collects aren't apparent to store owners.

Collects are for placing products in custom collections only. Smart collections use rules to determine which products are their members. Creating a collect that links a product to a smart collection results in a 403 Forbidden error.

For more information on custom collections, see the CustomCollection resource.

What you can do with Collect

The Shopify API lets you do the following with the Collect resource. More detailed versions of these general actions may be available:

Collect properties

collection_id
"collection_id": 841564295

The ID of the custom collection containing the product.

created_at
"created_at": "2018-04-25T13:51:12-04:00"

The date and time (ISO 8601 format) when the collect was created.

id
"id": 841564295

A unique numeric identifier for the collect.

position
"position": 2

The position of this product in a manually sorted custom collection. The first position is 1. This value is applied only when the custom collection is sorted manually.

product_id
"product_id": 632910392

The unique numeric identifier for the product in the custom collection.

sort_value
"sort_value": "0000000002"

This is the same value as position but padded with leading zeroes to make it alphanumeric-sortable.

updated_at
"updated_at": "2018-04-25T13:51:12-04:00"

The date and time (ISO 8601 format) when the collect was last updated.

Endpoints

POST /admin/collects.json
Adds a product to a custom collection.

Create a new link between an existing product and an existing collection

POST /admin/collects.json
{
  "collect": {
    "product_id": 921728736,
    "collection_id": 841564295
  }
}
View Response
HTTP/1.1 201 Created
{
  "collect": {
    "id": 1071559578,
    "collection_id": 841564295,
    "product_id": 921728736,
    "featured": false,
    "created_at": "2018-05-07T15:45:32-04:00",
    "updated_at": "2018-05-07T15:45:32-04:00",
    "position": 2,
    "sort_value": "0000000002"
  }
}

Creating a collect without a product or collection ID fails and returns an error

POST /admin/collects.json
{
  "collect": {
    "body": "foobar"
  }
}
View Response
HTTP/1.1 422 Unprocessable Entity
{
  "errors": {
    "product": [
      "can't be blank"
    ],
    "collection": [
      "can't be blank"
    ]
  }
}
DELETE /admin/collects/841564295.json
Removes a product from a collection.

Delete the link between a product an a collection

DELETE /admin/collects/#{collect_id}.json
View Response
HTTP/1.1 200 OK
{
}
GET /admin/collects.json
Retrieves a list of collects.
page

The page of results to show.

(default: 1)
limit

The maximum number of results to show.

(default: 50) (maximum: 250)
since_id

Restrict results to after the specified ID.

fields

Show only certain fields, specified by a comma-separated list of field names.

Retrieve all collects for the shop

GET /admin/collects.json
View Response
HTTP/1.1 200 OK
{
  "collects": [
    {
      "id": 395646240,
      "collection_id": 395646240,
      "product_id": 632910392,
      "featured": false,
      "created_at": null,
      "updated_at": null,
      "position": 1,
      "sort_value": "0000000001"
    },
    {
      "id": 841564295,
      "collection_id": 841564295,
      "product_id": 632910392,
      "featured": false,
      "created_at": null,
      "updated_at": null,
      "position": 1,
      "sort_value": "0000000001"
    }
  ]
}

Retrieve only collects for a certain product

GET /admin/collects.json?product_id=632910392
View Response
HTTP/1.1 200 OK
{
  "collects": [
    {
      "id": 395646240,
      "collection_id": 395646240,
      "product_id": 632910392,
      "featured": false,
      "created_at": null,
      "updated_at": null,
      "position": 1,
      "sort_value": "0000000001"
    },
    {
      "id": 841564295,
      "collection_id": 841564295,
      "product_id": 632910392,
      "featured": false,
      "created_at": null,
      "updated_at": null,
      "position": 1,
      "sort_value": "0000000001"
    }
  ]
}

Retrieve only collects for a certain collection

GET /admin/collects.json?collection_id=841564295
View Response
HTTP/1.1 200 OK
{
  "collects": [
    {
      "id": 1071559579,
      "collection_id": 841564295,
      "product_id": 921728736,
      "featured": false,
      "created_at": "2018-05-07T15:45:34-04:00",
      "updated_at": "2018-05-07T15:45:34-04:00",
      "position": 1,
      "sort_value": "0000000001"
    },
    {
      "id": 841564295,
      "collection_id": 841564295,
      "product_id": 632910392,
      "featured": false,
      "created_at": null,
      "updated_at": "2018-05-07T15:45:34-04:00",
      "position": 2,
      "sort_value": "0000000002"
    }
  ]
}
GET /admin/collects/count.json
Retrieves a count of collects.

Count all collects for the shop

GET /admin/collects/count.json
View Response
HTTP/1.1 200 OK
{
  "count": 2
}

Count only collects for a certain product

GET /admin/collects/count.json?product_id=632910392
View Response
HTTP/1.1 200 OK
{
  "count": 2
}

Count only collects for a certain collection

GET /admin/collects/count.json?collection_id=841564295
View Response
HTTP/1.1 200 OK
{
  "count": 1
}
GET /admin/collects/841564295.json
Retrieves a specific collect by its ID.
fields

Show only certain fields, specified by a comma-separated list of field names.

Retrieve a collect with a certain ID

GET /admin/collects/#{collect_id}.json
View Response
HTTP/1.1 200 OK
{
  "collect": {
    "id": 841564295,
    "collection_id": 841564295,
    "product_id": 632910392,
    "featured": false,
    "created_at": null,
    "updated_at": null,
    "position": 1,
    "sort_value": "0000000001"
  }
}