Skip to content

Loading a category by the API code

Aleksey Bobkov edited this page Jan 28, 2014 · 1 revision

You can load a category by its API code in a page, partial or template code using the category filter. Example:

{% set featuredCategory = 'featured'|category %}

The category object has the products variable that you can use to display the category products:

{% for product in featuredCategory.products %}
   <h3>{{ product.name }}</h3>
   ...
{% endfor %}

Or, if you use a product list partial:

{{ 
    partial('shop-product-list', {
        'products': featuredCategory.products,
        'empty_text': 'There are no products in this category.'
    }) 
}}