Collection
From Shopify Wiki
The liquid variable _collection_ has the following attributes:
Contents |
collection.id
Returns the id of this collection
collection.title
Returns the title of this collection
collection.handle
Returns this collection's handle, which is by default its title in lowercase. Whitespaces in the original title are replaced by dashes in the handle. The handle of a collection with the title "Winter Sale" would be "winter-sale".
collection.description
Returns the description of this collection
collection.products
Returns a collection of all products that are associated with this collection which match the current view. This takes into account things like paginate and selected tags. You can access each product by e.g. a for-iteration:
{% for product in collection.products %}
{{ product.title }}
{% endfor %}
collection.all_products
Returns a collection of all products that are associated with this collection.
Warning: This can potentially return thousands of products in one go and grind the Shopify servers to a halt. Please use this only with small product catalogs or use collection.products instead which is subject to pagination.
collection.tags
Returns all tags of all products on in this particular collection which match the current view. This means that if the current view is filtered to only products with a certain tags this variable will hold all the tags these remaining products actually have.
<ul>
{% for tag in tags %}
<li>{{ '+' | link_to_add_tag: tag }} {{ tag | link_to_tag: tag }}</li>
{% endfor %}
</ul>
collection.all_tags
This shows all tags associated with the collection.
collection.next_product and collection.previous_product
These methods are available if you scope your product pages to a certain collection. For a discussion read [[How To Navigate Within A Collection]]
collection.url
Returns the url for the specific collection.
