Product List Layouts

 Last Edited: Oct 24, 2019


  • - You have created Products in the Admin

Getting Started

This Tutorial will show you how to output a list of Products on your site.

It will cover how to:

  • - Find where Product layouts are stored on Code Editor
  • - Develop a wrapper.liquid file
  • - Develop an item.liquid file

Product Layout files in Code Editor

In SITE MANAGER/Code Editor, the folder structure for eCommerce layouts is as below:

  • layouts
    • modules
      • module_14
        • product
          • name_of_my_layout
            • list
              • wrapper.liquid
              • item.liquid
            • detail
              • wrapper.liquid
              • Item.liquid
          • product_attributes
            • my_attribute_layout.liquid

Creating a new set of Product Layouts

To create a new set of Product layouts- create your folder at the level of "name_of_my_layout". Inside that, the folders and files should be created as shown above.

List Layout Development

A list view for products is made up of two parts.


wrapper.liquid -- list view example

<div class="row"> <div class="card-deck"> {%- include 'modules/siteglide_ecommerce/ecommerce/get/get_products', item_layout: 'item' -%} </div> </div>

The wrapper contains the code for the main part of the section you are building. For example, the section title or some margin or padding that separates your list from other sections.

In the wrapper.liquid file, it is important to include the liquid file which loops over the Product items:

{%- include 'modules/siteglide_ecommerce/ecommerce/get/get_products', item_layout: 'item' -%}

The item_layout parameter should be the name of a liquid file in the same folder as the current file. Usually this will be "item", but you could have an alternative Layout.


item.liquid -- list view example

<div class="card"> <div class="card-img"> <a href="/{{this.module_slug}}/{{this.slug}}"><img src="{{this.Image | asset_url}}" alt="{{}}" class="card-img-top"></a> </div> <div class="card-body"> <a style="height: 100%" href="/{{this.module_slug}}/{{this.slug}}"> <h3 class="card-title">{{this['name']}}</h3> <p>{{this.price.currency_symbol}}{{this.price.price_charge_formatted}}</p> </a> </div> </div>

This file contains the code for each iteration of the loop that displays the Products. You should expect this code to be rendered multiple times; once for each product displayed in the list. (Hint: Try not to run any GraphQL calls inside a loop or item.liquid file, as they would have an impact on performance. It is better to run these inside the wrapper.)

As it is inside the loop, the item.liquid file has access to the "this" object and dynamic information specific to an individual product. A full reference for the fields you can use can be found here or you may find it convenient to output the "this" object on the page you are developing:

Output all data available in the "this" object.

{{this | json}}

Related Docs and Reference

See the Product Layout Reference Doc for fields you can use throughout your Product Layouts.