Collect

A collect is an object that connects a product to a custom collection.

Collect

For every product in a custom collection there exists a collect that tracks the ids of both the product and the custom collection it's a member of. A product can be a member of more than one collection, and will have more than one collect connecting the product to each collection. Unlike many Shopify resources, collects aren't apparent to shop owners; they're objects for managing the relationship between products and custom collections.

Reminder

Collects are for specifying the membership of 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.

What can you 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" : null }

The date and time when the collect was created. The API returns this value in ISO 8601 format.

id
{ "id" : 841564295 }

A unique numeric identifier for the collect.

position
{ "position" : 2 }

A number specifying the manually sorted position of this product in a custom collection. The first position is 1. This value only applies when the custom collection is viewed using the Manual sort order.

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" : null }

The date and time when the collect was last updated. The API returns this value in ISO 8601 format.

Endpoints

POST /admin/collects.json

Add a product to a collection

Trying to create a collect without a product or collection ID will return an error

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

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": 1071559595,
    "collection_id": 841564295,
    "product_id": 921728736,
    "featured": false,
    "created_at": "2016-11-09T13:52:55-05:00",
    "updated_at": "2016-11-09T13:52:55-05:00",
    "position": 2,
    "sort_value": "0000000002"
  }
}
DELETE /admin/collects/841564295.json

Remove a product from a collection

Destroy the link between a product an a collection

DELETE /admin/collects/#{id}.json
View Response
HTTP/1.1 200 OK
{}
GET /admin/collects.json

List all collects or only those for specific products or collections

page

Page to show

(default: 1)
limit

Collects per page

(default: 50) (maximum: 250)
fields

comma-separated list of fields to include in the response

List 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"
    }
  ]
}

List all collects for your 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"
    }
  ]
}

List only collects for a certain collection

GET /admin/collects.json?collection_id=841564295
View Response
HTTP/1.1 200 OK
{
  "collects": [
    {
      "id": 1071559593,
      "collection_id": 841564295,
      "product_id": 921728736,
      "featured": false,
      "created_at": "2016-11-09T13:52:51-05:00",
      "updated_at": "2016-11-09T13:52:51-05:00",
      "position": 1,
      "sort_value": "0000000001"
    },
    {
      "id": 841564295,
      "collection_id": 841564295,
      "product_id": 632910392,
      "featured": false,
      "created_at": null,
      "updated_at": null,
      "position": 2,
      "sort_value": "0000000002"
    }
  ]
}
GET /admin/collects/count.json

Get a count of all collects or only those for specific products or collections

Count only collects for a certain collection

GET /admin/collects/count.json?collection_id=841564295
View Response
HTTP/1.1 200 OK
{
  "count": 1
}

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 all collects for your shop

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

Get the collect with a certain id, or for a given product AND collection

fields

comma-separated list of fields to include in the response

Return a collect with a certain id

GET /admin/collects/#{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"
  }
}