collection

The collection object has the following attributes:

collection.all_tags

Returns a list of all product tags in a collection. collection.all_tags will return the full list of tags even when the collection view is filtered.

collection.all_tags will return at most 1,000 tags.

In comparison, collection.tags returns all tags for a collection for the current view. For example, if a collection is filtered by tag, collection.tags returns only the tags that match the current filter.

collection.all_types

Returns a list of all product types in a collection.

Input

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

Output

<a href="/collections/types?q=Accessories" title="Accessories">Accessories</a>
<a href="/collections/types?q=Chairs" title="Chairs">Chairs</a>
<a href="/collections/types?q=Shoes" title="Shoes">Shoes</a>

collection.all_products_count

Returns the number of products in a collection. collection.all_products_count will return the total number of products even when the collection view is filtered.

In comparison, collection.products_count returns all tags for a collection for the current view. For example, if a collection is filtered by tag, collection.products_count returns the number of products that match the current filter.

Input

{{ collection.all_products_count }} total products in this collection

Output

24 total products in this collection

collection.all_vendors

Returns a list of all product vendors in a collection.

Input

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

Output

<a href="/collections/vendors?q=Shopify" title="Shopify">Shopify</a>
<a href="/collections/vendors?q=Shirt+Company" title="Shirt Company">Shirt Company</a>
<a href="/collections/vendors?q=Montezuma" title="Montezuma">Montezuma</a>

collection.current_type

Returns the product type on a /collections/types?q=TYPE collection page. For example, an automatic "Shirts" collection lists all products of type "Shirts" in the store: yourstore.myshopify.com/collections/types?q=Shirts.

Input

{% if collection.current_type %}
Browse all our {{ collection.current_type | downcase }}.
{% endif %}

Output

Browse all our shirts.

collection.current_vendor

Returns the product vendor on a /collections/vendores?q=VENDOR collection page. For example, an automatic "ApparelCo" collection lists all products with the vendor "ApparelCo" in the store: yourstore.myshopify.com/collections/vendors?q=ApparelCo.

Input

{% if collection.current_vendor %}
All products by {{ collection.current_vendor }}.
{% endif %}

Output

All products by ApparelCo.

collection.default_sort_by

Returns the sort order of the collection, which is set on the collection's page in your Shopify admin.

Collection sorting

The possible sort orders are:

  • manual
  • best-selling
  • title-ascending
  • title-descending
  • price-ascending
  • price-descending
  • created-ascending
  • created-descending

collection.description

Returns the description of the collection.

collection.handle

Returns the collection's handle.

collection.id

Returns the ID number of the collection.

collection.image

Returns the collection image. Use the img_url filter to load the image file from the Shopify content delivery network (CDN). Use an if tag to check for the presence of the image first.

Input

{% if collection.image %}{{ collection.image | img_url: 'medium' }}{% endif %}

Output

//cdn.shopify.com/s/files/1/0087/0462/collections/collection-image_medium.png?v=1337103726

collection.next_product

Returns the URL of the next product in the collection. Returns nil if there is no next product.

You can use collection.next_product and collection_previous product with the within filter to create "next" and "previous" links in the product.liquid template.

collection.previous_product

Returns the URL of the previous product in the collection. Returns nil if there is no previous product.

You can use collection.next_product and collection_previous product with the within filter to create "next" and "previous" links in the product.liquid template.

collection.products

Returns all of the products in a collection. You can show a maximum of 50 products per page.

Use the paginate tag to choose how many products are shown per page.

collection.products_count

Returns the number of products in a collection that match the current view. For example, if you are viewing a collection filtered by tag, collection.products_count will return the number of products that match the chosen tag.

Input

{{ collection.products_count }} products

Output

6 products

collection.published_at

Returns the date and time when the collection was published. You can set this information on the collection's page in your Shopify admin by the Set publish date calendar icon.

You can use a date filter to format the date.

collection.template_suffix

Returns the name of the custom collection template assigned to the collection, without the collection. prefix or the .liquid suffix. Returns nil if a custom template is not assigned to the collection.

Input

{{ collection.template_suffix }}

Output

no-price

collection.title

Returns the title of the collection.

Input

<h1>{{ collection.title }}</h1>

Output

<h1>Frontpage</h1>

collection.tags

Returns the tags of products in a collection that match the current view. For example, if you are viewing a collection filtered by tag, collection.tags will return the tags for the products that match the current filter.

collection.url

Returns the URL of the collection.

Want to discuss this page?

Visit the Shopify Community