Skip to main content
Glama
collection.md3.14 kB
# Collection Object - Liquid Documentation ## Overview The collection object represents a product collection within a Shopify store. It provides access to collection metadata, filtering options, and product data. ## Properties Reference ### Basic Information - **id** (number): Unique identifier for the collection - **handle** (string): URL-friendly identifier for the collection - **title** (string): Display name of the collection - **description** (string): Description text for the collection - **url** (string): Relative URL path to access the collection ### Images - **image** (image object): Collection image uploaded in Shopify admin - **featured_image** (image object): Primary display image; defaults to collection image, then first product's featured image ### Product Data - **products** (array): All products within the collection - **products_count** (number): Product count in current filtered view - **all_products_count** (number): Total products including filtered-out items - **next_product** (product): Following product in collection (nil if unavailable) - **previous_product** (product): Previous product in collection (nil if unavailable) ### Filtering & Tags - **all_tags** (array): Tags from all products (max 1,000); includes filtered items - **tags** (array): Currently applied tags; excludes filtered products - **all_types** (array): All product types in collection - **current_type** (string): Active type filter on `/collections/types` pages - **all_vendors** (array): All product vendors in collection - **current_vendor** (string): Active vendor filter on `/collections/vendors` pages - **filters** (array): Configured storefront filters (unavailable for collections exceeding 5,000 products) ### Sorting - **default_sort_by** (string): Admin-configured default sort order - **sort_by** (string): Active sort parameter; nil if none applied - **sort_options** (array): Available sorting methods Valid sort values include: manual, best-selling, title-ascending, title-descending, price-ascending, price-descending, created-ascending, created-descending ### Administrative - **published_at** (string): Timestamp of collection publication - **metafields** (array): Custom metadata fields applied to collection - **template_suffix** (string): Assigned custom template name (without prefix/extension) ## Code Example: Sort Options ```liquid {%- 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> ``` ## Code Example: Product Type Links Use the `link_to_type` filter to generate type-based product links: ```liquid {% for product_type in collection.all_types -%} {{- product_type | link_to_type }} {%- endfor %} ``` ## Code Example: Vendor Links Use the `link_to_vendor` filter to create vendor-based links: ```liquid {% for product_vendor in collection.all_vendors %} {{- product_vendor | link_to_vendor }} {% endfor %} ```

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/florinel-chis/shopify-liquid-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server