Skip to content

Collection

The Collection object represents a single collection of products in the storefront.

classDiagram
  direction LR
  Collection --> ProductsList
  Collection --> CollectionUrl
  ProductsList "1" --o "*" Product
  class Product{
  }
  class ProductsList{
  }
  class CollectionUrl{
  }
  class Collection{
    int id
    string name
    CollectionUrl url
    string description
    string additionalDescription
    Metafields metafields
    ProductsList products
  }

Properties

Attribute name Type Description
id int The unique identifier of the collection.
name string The name of the collection.
url CollectionUrl The CollectionUrl object that represents the url to the collection.
description string The description of the collection.
additionalDescription string The additional description of the collection.
metafields Metafields Reference to the Metafields object that provides access to the namespaced containers for key - value pairs of data.
products ProductsList Reference to the ProductsList object that represents the list of Product objects associated with this collection.

Examples

id property

{{ collection.id }}
1

name property

{{ collection.name }}
example name

url property

{{ collection.url }}
/example/url

description property

{{ collection.description }}
example description

additionalDescription property

{{ collection.additionalDescription }}
example additional description

metafields property

value: {{ collection.metafields.someNamespaceName.key }}
value: example-value-2

products property

{% for product in collection.products %}
    <a href="{{ product.url }}" title="{{ product.name }}">
        {{ product.name }}
    </a>
{% endfor %}
<a href="/en/p/product-in-collection/11" title="Product in collection">
    Product in collection
</a>
<a href="/en/p/product-in-collection-2/12" title="Product in collection 2">
    Product in collection 2
</a>