A smart collection is a grouping of products defined by simple rules set by shop owners. A shop owner creates a smart collection and then sets the rules that determine which products go in them. haravan automatically changes the contents of smart collections based on their rules.
Smart Collections also use collects to connect a product to that smart collection. These collects, however, are managed by the rules of the smart collection and therefore cannot be added or removed through the API.
Haravan's collections — both smart collections and custom collections — are typically displayed to customers so that customers can select them and then view only the products in the collection they selected. They're typically used to break down the catalog of products into categories and make the shop easier to browse.
In addition to smart collections, there are also custom collections, which are groupings of products defined by the shop owner.
Authenticated access scopes: com.read_products, com.write_products
What you can do with SmartCollection
The Haravan API lets you do the following with the SmartCollection resource.
- GET https://apis.haravan.com/com/smart_collections.json Retrieves a list of smart collections.
- GET https://apis.haravan.com/comsmart_collections/count.json Retrieves a count of smart collections.
- GET https://apis.haravan.com/com/smart_collections/{smart_collections_id}.json Retrieves detail a smart collection.
- POST https://apis.haravan.com/com/smart_collections.json Create a smart collection.
- PUT https://apis.haravan.com/com/smart_collections/{smart_collections_id}.json Update a smart collection.
- PUT https://apis.haravan.com/com/smart_collections/{smart_collections_id}/order.json Set the ordering type and/or the manual order of products in a smart collection.
- DELETE https://apis.haravan.com/com/smart_collections/{smart_collections_id}.json Delete a smart collection.
SmartCollection properties
Endpoints
limit | Limit of the result. |
page | Page to show the result. |
since_id | Restrict results to after the specified ID. |
title | Filter result by the title. |
product_id | Filter result by the product id. |
handle | Filter result by the handle. |
updated_at_min | Show smart collections last updated after date (format: 2008-12-31 03:00). |
updated_at_min | Show smart collections last updated after date (format: 2008-12-31 03:00). |
updated_at_max | Show smart collections last updated before date (format: 2008-12-31 03:00). |
published_at_min | Show smart collections last updated after date (format: 2008-12-31 03:00). |
published_at_max | Show smart collections last updated before date (format: 2008-12-31 03:00). |
published_status |
|
fields | Comma-separated list of fields to include in the response. |
Retrieve all smart collections by page number. By default, the number of resources on the page is 50.
GET https://apis.haravan.com/com/smart_collections.json?page=1
HTTP/1.1 200 OK
{ "smart_collections": [ { "body_html": null, "handle": "km-20", "id": 1002448475, "image": null, "published_at": "2020-12-03T09:42:28.751Z", "published_scope": "global", "rules": [ { "relation": "equals", "condition": "KM20", "column": "tag" } ], "disjunctive": true, "sort_order": "alpha_asc", "template_suffix": "collection", "title": "KM 20%", "updated_at": "2020-12-03T09:43:02.959Z" } ] }
Retrieve all smart collections by title.
GET https://apis.haravan.com/com/smart_collections.json?title=km
HTTP/1.1 200 OK
{ "smart_collections": [ { "body_html": null, "handle": "km-20", "id": 1002448475, "image": null, "published_at": "2020-12-03T09:42:28.751Z", "published_scope": "global", "rules": [ { "relation": "equals", "condition": "KM20", "column": "tag" } ], "disjunctive": true, "sort_order": "alpha_asc", "template_suffix": "collection", "title": "KM 20%", "updated_at": "2020-12-03T09:43:02.959Z" } ] }
Retrieve all smart collections by product id.
GET https://apis.haravan.com/com/smart_collections.json?product_id=1028183686
HTTP/1.1 200 OK
{ "smart_collections": [ { "body_html": null, "handle": "km-20", "id": 1002448475, "image": null, "published_at": "2020-12-03T09:42:28.751Z", "published_scope": "global", "rules": [ { "relation": "equals", "condition": "KM20", "column": "tag" } ], "disjunctive": true, "sort_order": "alpha_asc", "template_suffix": "collection", "title": "KM 20%", "updated_at": "2020-12-03T09:43:02.959Z" } ] }
Retrieves a count of all smart collections.
Count all smart collections for your shop.
GET https://apis.haravan.com/com/smart_collections/count.json
HTTP/1.1 200 OK
{ "count": 1 }
Count only collects for a certain product.
GET https://apis.haravan.com/com/smart_collections/count.json?product_id=1028183686
HTTP/1.1 200 OK
{ "count": 1 }
Retrieves detail a smart collection.
Retrieves detail a smart collection with id.
GET https://apis.haravan.con/com/smart_collections/1002448475.json
HTTP/1.1 200 OK
{ "smart_collection": { "body_html": null, "handle": "km-20", "id": 1002448475, "image": null, "published_at": "2020-12-03T09:42:28.751Z", "published_scope": "global", "rules": [ { "relation": "equals", "condition": "KM20", "column": "tag" } ], "disjunctive": true, "sort_order": "alpha_asc", "template_suffix": "collection", "title": "KM 20%", "updated_at": "2020-12-03T09:43:02.959Z" } }
Create a smart collection.
Valid values for Rule fields:
- column - title, type, vendor, variant_price, variant_compare_at_price, variant_weight, variant_inventory, variant_title
- relation - equals, greater_than, less_than, starts_with, ends_with, contains
- condition - any string
Create a collection of all products starting with the term iPod.
POST https://apis.haravan.com/com/smart_collection.json
{ "smart_collection": { "title": "IPods", "rules": [ { "column": "title", "relation": "starts_with", "condition": "iPod" } ] } }
HTTP/1.1 201 Created
{ "smart_collection": { "body_html": null, "handle": "ipods", "id": 1002798878, "image": { "src": null, "created_at": null }, "published_at": "2021-08-18T11:25:28.1096473Z", "published_scope": null, "rules": [ { "relation": "starts_with", "condition": "iPod", "column": "title" } ], "disjunctive": false, "sort_order": "alpha_asc", "template_suffix": "collection", "title": "IPods", "updated_at": "2021-08-18T11:25:28.1881035Z", "products_count": 0 } }
Update a smart collection.
Change the description of a smart collection.
PUT https://apis.haravan.com/com/smart_collections/841564295.json
{ "smart_collection": { "body_html": "5000 songs in your pocket
" } }
HTTP/1.1 200 Ok
{ "smart_collection": { "body_html": null, "handle": "ipods", "id": 1002798878, "image": null, "published_at": "2021-08-18T11:25:28.11Z", "published_scope": "web", "rules": [ { "relation": "starts_with", "condition": "iPod", "column": "title" } ], "disjunctive": false, "sort_order": "alpha_asc", "template_suffix": "collection", "title": "IPods", "updated_at": "2021-08-18T11:25:28.188Z" } }
Set the ordering type and/or the manual order of products in a smart collection.
- products: Array of product ids in the order you want them arranged. (Applies only when sort_order is set to "manual")
- sort_order: The type of sorting to apply. Valid values are listed in the Properties section above. (default: (current value))
Change the manual ordering of products in the smart collection.
{}
HTTP/1.1 200 Ok
{}
Change the manual ordering of products in the smart collection.
PUT https://apis.haravan.com/com/smart_collections/841564295/order.json?sort_order=alpha-desc
{}
HTTP/1.1 200 Ok
{}
Delete a smart collection.
Delete a smart collection.
Delete https://apis.haravan.com/com/smart_collections/1002798878.json
{}
HTTP/1.1 200 OK
[]