Skip to main content

collection

A collection in a store.

Properties

Anchor to
all_products_count

The total number of products in a collection.

This includes products that have been filtered out of the current view.

Tip

To display the number of products in a filtered collection, use collection.products_count.

Anchor to
all_tags
array of string

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.

Tip

To display the tags that are currently applied, use collection.tags.

Anchor to
all_types
array of string

All of the product types in a collection.

Example
Create links to product types

Use the link_to_type filter to create links to the product types in a collection.

{% for product_type in collection.all_types -%}
{{- product_type | link_to_type }}
{%- endfor %}

Output

<a href="/collections/types?q=Animals%20%26%20Pet%20Supplies" title="Animals &amp; Pet Supplies">Animals & Pet Supplies</a>
<a href="/collections/types?q=Baking%20Flavors%20%26%20Extracts" title="Baking Flavors &amp; Extracts">Baking Flavors & Extracts</a>
<a href="/collections/types?q=Cooking%20%26%20Baking%20Ingredients" title="Cooking &amp; 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 &amp; Vegetables">Fruits & Vegetables</a>
<a href="/collections/types?q=Seasonings%20%26%20Spices" title="Seasonings &amp; Spices">Seasonings & Spices</a>
<a href="/collections/types?q=Water" title="Water">Water</a>
Anchor to
all_vendors
array of string

All of the product vendors in a collection.

Example
Create links to vendors

Use the link_to_vendor filter to create links to the vendors in a collection.

{% for product_vendor in collection.all_vendors %}
{{- product_vendor | link_to_vendor }}
{% endfor %}

Output

<a href="/collections/vendors?q=Clover%27s%20Apothecary" title="Clover&#39;s Apothecary">Clover's Apothecary</a>

<a href="/collections/vendors?q=Polina%27s%20Potent%20Potions" title="Polina&#39;s Potent Potions">Polina's Potent Potions</a>

<a href="/collections/vendors?q=Ted%27s%20Apothecary%20Supply" title="Ted&#39;s Apothecary Supply">Ted's Apothecary Supply</a>
Anchor to
current_type

The product type on a product type collection page.

You can query for products of a certain type at the /collections/types URL with a query parameter in the format of ?q=[type], where [type] is your desired product type.

Tip

The query value is case-insensitive, so shirts is equivalent to Shirts or SHIRTS.

Anchor to
current_vendor

The vendor name on a vendor collection page.

You can query for products from a certain vendor at the /collections/vendors URL with a query parameter in the format of ?q=[vendor], where [vendor] is your desired product vendor.

Tip

The query value is case-insensitive, so apparelco is equivalent to ApparelCo or APPARELCO.

Anchor to
default_sort_by
string from a set of values

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
Anchor to
description

The description of the collection.

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.

Anchor to
filters
array of filter

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 handle of the collection.

The ID of the collection.

The image for the collection.

This image is added on the collection's page in the Shopify admin.

Anchor to
metafields
array of metafield

The metafields applied to the collection.

Tip

To learn about how to create metafields, refer to Create and manage metafields or visit the Shopify Help Center.

Anchor to
next_product

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.

Anchor to
previous_product

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.

Anchor to
products
array of product

All of the products in the collection.

Tip

Use the paginate tag to choose how many products to show per page, up to a limit of 50.

Anchor to
products_count

The total number of products in the current view of the collection.

Anchor to
published_at

A timestamp for when the collection was published.

Tip

Use the date filter to format the timestamp.

The sort order applied to the collection by the sort_by URL parameter.

If there's no sort_by URL parameter, then the value is nil.

Anchor to
sort_options
array of sort_option

The available sorting options for the collection.

Example
Output the sort options
{%- 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>

Output

<select>
<option
value="manual"
>
Featured
</option>

<option
value="best-selling"
>
Best selling
</option>

<option
value="title-ascending"
selected="selected"
>
Alphabetically, A-Z
</option>

<option
value="title-descending"
>
Alphabetically, Z-A
</option>

<option
value="price-ascending"
>
Price, low to high
</option>

<option
value="price-descending"
>
Price, high to low
</option>

<option
value="created-ascending"
>
Date, old to new
</option>

<option
value="created-descending"
>
Date, new to old
</option>
</select>
Anchor to
tags
array of string

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.

Anchor to
template_suffix

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.

The title of the collection.

The relative URL of the collection.

{
"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": {}
}
Was this section helpful?