collection
A collection in a store.
Properties
The total number of products in a collection.
All of the tags applied to the products in the collection.
This includes tags for products that have been filtered out of the current view. A maximum of 1,000 tags can be returned.
TipTo display the tags that are currently applied, use
collection.tags
.All of the product types in a collection.
ExampleCreate links to product types{% for product_type in collection.all_types -%}{{- product_type | link_to_type }}{%- endfor %}{% for product_type in collection.all_types -%} {{- product_type | link_to_type }} {%- endfor %}
{ "collection": { "all_types": [ "Animals & Pet Supplies", "Baking Flavors & Extracts", "Cooking & Baking Ingredients", "Dried Flowers", "Fruits & Vegetables", "Seasonings & Spices", "Water" ] } }
Output
<a href="/collections/types?q=Animals%20%26%20Pet%20Supplies" title="Animals & Pet Supplies">Animals & Pet Supplies</a><a href="/collections/types?q=Baking%20Flavors%20%26%20Extracts" title="Baking Flavors & Extracts">Baking Flavors & Extracts</a><a href="/collections/types?q=Cooking%20%26%20Baking%20Ingredients" title="Cooking & Baking Ingredients">Cooking & Baking Ingredients</a><a href="/collections/types?q=Dried%20Flowers" title="Dried Flowers">Dried Flowers</a><a href="/collections/types?q=Fruits%20%26%20Vegetables" title="Fruits & Vegetables">Fruits & Vegetables</a><a href="/collections/types?q=Seasonings%20%26%20Spices" title="Seasonings & Spices">Seasonings & Spices</a><a href="/collections/types?q=Water" title="Water">Water</a>All of the product vendors in a collection.
ExampleCreate links to vendors{% for product_vendor in collection.all_vendors %}{{- product_vendor | link_to_vendor }}{% endfor %}{% for product_vendor in collection.all_vendors %} {{- product_vendor | link_to_vendor }} {% endfor %}
{ "collection": { "all_vendors": [ "Clover's Apothecary", "Polina's Potent Potions", "Ted's Apothecary Supply" ] } }
Output
<a href="/collections/vendors?q=Clover%27s%20Apothecary" title="Clover's Apothecary">Clover's Apothecary</a><a href="/collections/vendors?q=Polina%27s%20Potent%20Potions" title="Polina's Potent Potions">Polina's Potent Potions</a><a href="/collections/vendors?q=Ted%27s%20Apothecary%20Supply" title="Ted's Apothecary Supply">Ted's Apothecary Supply</a>The product type on a product type collection page.
You can query for products of a certain type at the
URL with a query parameter in the format of
?q=[type]
, where[type]
is your desired product type.TipThe query value is case-insensitive, so
shirts
is equivalent toShirts
or.
The vendor name on a vendor collection page.
You can query for products from a certain vendor at the
URL with a query parameter in the format of
?q=[vendor]
, where[vendor]
is your desired product vendor.TipThe query value is case-insensitive, so
apparelco
is equivalent toor
.
The default sort order of the collection.
This is set on the collection's page in the Shopify admin.
Possible values manual best-selling title-ascending price-ascending price-descending created-ascending created-descending The featured image for the collection.
The default is the collection image. If this image isn't available, then Shopify falls back to the featured image of the first product in the collection. If the first product in the collection doesn't have a featured image, then
nil
is returned.The storefront filters that have been set up on the collection.
Only filters relevant to the current collection are returned. Filters will be empty for collections that contain over 5000 products.
To learn about supporting filters in your theme, refer to Support storefront filtering.
The image for the collection.
This image is added on the collection's page in the Shopify admin.
The metafields applied to the collection.
TipTo learn about how to create metafields, refer to Create and manage metafields or visit the Shopify Help Center.
The next product in the collection. Returns
nil
if there's no next product.This property can be used on the product page to output
next
links.The previous product in the collection. Returns
nil
if there's no previous product.This property can be used on the product page to output
previous
links.All of the products in the collection.
TipUse the paginate tag to choose how many products to show per page, up to a limit of 50.
A timestamp for when the collection was published.
TipUse the
date
filter to format the timestamp.The sort order applied to the collection by the
URL parameter.
If there's no
URL parameter, then the value is
nil
.- sort_
options array of sort_option The available sorting options for the collection.
ExampleOutput the sort options{%- assign sort_by = collection.sort_by | default: collection.default_sort_by -%}<select>{%- for option in collection.sort_options %}<optionvalue="{{ option.value }}"{%- if option.value == sort_by %}selected="selected"{%- endif %}>{{ option.name }}</option>{% endfor -%}</select>{%- assign sort_by = collection.sort_by | default: collection.default_sort_by -%} <select> {%- for option in collection.sort_options %} <option value="{{ option.value }}" {%- if option.value == sort_by %} selected="selected" {%- endif %} > {{ option.name }} </option> {% endfor -%} </select>
{ "collection": { "default_sort_by": "title-ascending", "sort_by": "", "sort_options": [ "CollectionDrop::SortOptionDrop", "CollectionDrop::SortOptionDrop", "CollectionDrop::SortOptionDrop", "CollectionDrop::SortOptionDrop", "CollectionDrop::SortOptionDrop", "CollectionDrop::SortOptionDrop", "CollectionDrop::SortOptionDrop", "CollectionDrop::SortOptionDrop" ] } }
Output
<select><optionvalue="manual">Featured</option><optionvalue="best-selling">Best selling</option><optionvalue="title-ascending"selected="selected">Alphabetically, A-Z</option><optionvalue="title-descending">Alphabetically, Z-A</option><optionvalue="price-ascending">Price, low to high</option><optionvalue="price-descending">Price, high to low</option><optionvalue="created-ascending">Date, old to new</option><optionvalue="created-descending">Date, new to old</option></select>The tags that are currently applied to the collection.
This doesn't include tags for products that have been filtered out of the current view. Returns
nil
if no tags have been applied, or all products with tags have been filtered out of the current view.The name of the custom template assigned to the collection.
The name doesn't include the
collection.
prefix, or the file extension (.json
or.liquid
).If a custom template isn't assigned to the collection, then
nil
is returned.
{
"all_products_count": 10,
"all_tags": [
"Burning",
"dried",
"extracts",
"fresh",
"ingredients",
"plant",
"supplies"
],
"all_types": [
"Animals & Pet Supplies",
"Baking Flavors & Extracts",
"Cooking & Baking Ingredients",
"Dried Flowers",
"Fruits & Vegetables",
"Seasonings & Spices",
"Water"
],
"all_vendors": [
"Clover's Apothecary",
"Polina's Potent Potions",
"Ted's Apothecary Supply"
],
"current_type": null,
"current_vendor": null,
"default_sort_by": "created-ascending",
"description": "Brew your own potions at home using our fresh, ethically-sourced ingredients.",
"featured_image": {},
"filters": {},
"handle": "ingredients",
"id": 266168401985,
"image": {},
"metafields": {},
"next_product": null,
"previous_product": null,
"products": {},
"products_count": 1,
"published_at": "2022-04-19 09:52:18 -0400",
"sort_by": "",
"sort_options": [],
"tags": [
"Burning"
],
"template_suffix": "eight-products-per-page",
"title": "Ingredients",
"url": {}
}