A collect is an object that connects a product to a custom collection.
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 haravan resources, collects aren't apparent to shop owners; they're objects for managing the relationship between products and custom collections.
Authenticated access scopes: com.read_products, com.write_products
What you can do with Collect
The Haravan API lets you do the following with the Collect resource.
- GET https://apis.haravan.com/com/collects.json Retrieves a list of collects.
- GET https://apis.haravan.com/com/collects/count.json Retrieves a count of all collects.
- GET https://apis.haravan.com/com/collects/{collect_id}.json Retrieves detail a collects.
- POST https://apis.haravan.com/com/collects.json Create a collect.
- DELETE https://apis.haravan.com/com/collects/{collect_id}.json Delete a collect.
Collect properties
Endpoints
limit | Limit of the result (Max: 500). |
page | Page to show the result. |
collection_id | Filter result by the collection id. |
product_id | Filter result by the product id. |
fields | Comma-separated list of fields to include in the response. |
Retrieve all collects by page number. By default, the number of resources on the page is 50. (Max: 500)
GET https://apis.haravan.com/com/collects.json?page=1&limit=50
HTTP/1.1 200 OK
{ "collects": [ { "collection_id": 395646240, "created_at": null, "featured": false, "id": 395646240, "position": 1, "product_id": 632910392, "updated_at": null, "sort_value": "0000000001" }, { "collection_id": 841564295, "created_at": null, "featured": false, "id": 841564295, "position": 1, "product_id": 632910392, "updated_at": null, "sort_value": "0000000001" } ] }
Retrieve all collects by collection id.
GET https://apis.haravan.com/com/collects.json?colection_id=1002507494
HTTP/1.1 200 OK
{ "collects": [ { "collection_id": 1002507494, "created_at": "2021-01-13T12:28:01.614Z", "featured": false, "id": 1059375051, "position": 0, "product_id": 1028183633, "sort_value": "0000000000", "updated_at": "2021-01-13T12:28:02.614Z" } ] }
Retrieve all collects by product id.
GET https://apis.haravan.com/com/collects.json?product_id=1028183633
HTTP/1.1 200 OK
{ "collects": [ { "collection_id": 1002507492, "created_at": "2021-01-13T12:28:01.248Z", "featured": false, "id": 1059375049, "position": 0, "product_id": 1028183633, "sort_value": "0000000000", "updated_at": "2021-01-13T12:28:02.248Z" }, { "collection_id": 1002507493, "created_at": "2021-01-13T12:28:01.431Z", "featured": false, "id": 1059375050, "position": 0, "product_id": 1028183633, "sort_value": "0000000000", "updated_at": "2021-01-13T12:28:02.431Z" } ] }
Count all collects for your shop.
GET /com/collects/count.json
HTTP/1.1 200 OK
{ "count": 2 }
Count only collects for a certain collection.
GET https://apis.haravan.com/com/collects/count.json?collection_id=841564295
HTTP/1.1 200 OK
{ "count": 1 }
Count only collects for a certain product.
GET https://apis.haravan.com/com/collects/count.json?product_id=632910392
HTTP/1.1 200 OK
{ "count": 2 }
Retrieves detail a collect with id.
GET https://apis.haravan.com/com/collects/841564295.json
HTTP/1.1 200 OK
{ "collect": { "collection_id": 841564295, "created_at": null, "featured": false, "id": 841564295, "position": 1, "product_id": 632910392, "updated_at": null, "sort_value": "0000000001" } }
Create a collect.
Note: 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.
Create a collect.
POST https://apis.haravan.com/com/collects.json
{ "collect": { "product_id": 921728736, "collection_id": 841564295 } }
HTTP/1.1 201 Created
{ "collect": { "collection_id": 841564295, "created_at": "2015-03-28T13:27:21-04:00", "featured": false, "id": 1071559574, "position": 2, "product_id": 921728736, "updated_at": "2015-03-28T13:27:21-04:00", "sort_value": "0000000002" } }