Objetos /
collection
Una colección con sus productos, filtros y opciones de orden.
Dónde está
Global en la página de colección (templates/collection.json). También en settings de tipo collection y collection_list.
Propiedades
| Propiedad | Tipo | Qué es |
|---|---|---|
collection.id | texto o nil | Identificador (nil en all). |
collection.title | texto | Título. |
collection.handle | texto | Handle. |
collection.url | texto | /collections/<handle>. |
collection.description | HTML | Descripción con formato. |
collection.products | array de product | Productos de la página actual. |
collection.products_count | número | Productos que coinciden con los filtros. |
collection.all_products_count | número | Productos de toda la colección. |
collection.featured_image | image o nil | Imagen de la colección. |
collection.metafields | objeto | collection.metafields.<namespace>.<key>. |
collection.sort_options | array | Órdenes posibles, cada uno con name y value. |
collection.sort_by | texto o nil | Orden actual (parámetro sort_by). |
collection.default_sort_by | texto o nil | Orden por defecto. |
collection.filters | array de filter | Filtros del listado. |
Ejemplo
<h1>{{ collection.title }}</h1>
<p>{{ 'collections.products_count' | t: count: collection.products_count }}</p>
{% paginate collection.products by 24 %}
<ul>
{% for product in collection.products %}
<li><a href="{{ product.url }}">{{ product.title }}</a></li>
{% endfor %}
</ul>
{% endpaginate %}Notas
- En la página de colección,
collection.productstrae solo los de la página actual: usápaginatepara los links.