Product Loop

Product loop lists products from your shop. You very probably will have to use the product sale elements loop inside your product loop.

{loop type="product" name="the-loop-name" [argument="value"], [...]}

Important informations :

* : argument is required
** : at least one of ** marked argument is required

Global arguments

Argument Description
backend_context

Determine if loop is use in backend context.

default : false

example : backend_context="on"

force_return

force return result for i18n tables even if there is no record

default : false

example : force_return="on"

limit

The maximum number of results to display.

example : limit="10"

name *

The loop name. This name must be unique and is used to reference this loop further in the page (see ifloop, elseloop or pageloop)

offset

The first product to display offset. Will not be used if `page` argument is set.

default : 0

example : offset="1"

page

The page to display.

example : page="2"

Text search arguments
Argument Description
search_in

A comma separeted list of field in which the search is performed

Possible values : ref, title, chapo, description, postscriptum

example : search_in="title"

search_mode

the search mode : `any_word` (search any word separeted by a space), `sentence` (the sentence, anywhere in the field) or `strict_sentence` (the exact sentence)

default : strict_sentence

search_term

The term to search

example : search_term="my product"

Loop arguments

Argument Description
attribute_non_strict_match

Only available if complex='true'
promo, new, quantity, weight or price may differ in the different product sale element depending on the different attributes. This parameter allows to provide a list of non-strict attributes.

Expected values :
  • * : all the attributes are non strict
  • max_price
  • max_weight
  • min_price
  • min_stock
  • min_weight
  • new
  • none : product loop will look for at least 1 attribute which matches all the loop criteria.
  • promo

default : none

example : attribute_non_strict_match="promo,new" : loop will return the product if it has at least a product sale element in promo and at least a product sale element as new ; even if it's not the same product sale element.

brand

A single or a list of brand ids.

example : brand="2", brand="1,4,7"

category

A single or a list of category ids.

example : category="2", category="1,4,7"

category_default

A single or a list of default category ids allowing to retrieve all products having this parameter as default category.

example : category_default="2", category_default="1,4,7"

complex

A boolean. If set to true, product loop will consider all product sale elements else it will only consider default product sale element. Some of the arguments/outputs will not be available depending on the complex argument.

default : false

example : complex="true"

content
Thelia >= 2.3

One or more content ID. When this parameter is set, the loop returns the products related to the specified content IDs.

example : content="3"

currency

A currency id

example : currency="1"

current

A boolean value which allows either to exclude current product from results either to match only this product

example : current="yes"

current_category

A boolean value which allows either to exclude current category products from results either to match only current category products. If a product is in multiple categories whose one is current it will not be excluded if current_category="false" but will be included if current_category="yes"

example : current_category="yes"

depth

A positive integer value which precise how many subcategory levels will be browse. Will not be consider if category parameter is not set.

default : 1

example : depth="2"

exclude

A single or a list of product ids.

example : exclude="2", exclude="1,4,7"

exclude_category

A single or a list of category ids. If a product is in multiple categories which are not all excluded it will not be excluded.

example : exclude_category="2", exclude_category="1,4,7"

feature_availability

A list of mandatory features and the feature_availability expected for these.

example : feature_availability="1: (1 | 2) , 2:*, 3: 10 | (11&12)" : feature 1 must have feature_availability 1 or 2 AND feature 2 must be set to any feature_availability AND feature 3 must have feature_availability 10 or both feature_availability 11 and 12

feature_values

A list of mandatory features and the string value expected for these.

example : feature_availability="1: (foo | bar) , 2:*, 3: foobar" : feature 1 must have feature value "foo" or "bar" AND feature 2 must be set to any feature_availability AND feature 3 must have feature value "foobar"

id

A single or a list of product ids.

example : id="2", id="1,4,7"

lang

A lang id

example : lang="1"

max_price

A float value. Equal value matches.

example : max_price="32.1"

max_weight

A float value. Equal value matches.

example : max_weight="32.1"

min_price

A float value. Equal value matches.

example : min_price="12.3"

min_stock

An integer value. Equal value matches.

example : min_stock="3"

min_weight

A float value. Equal value matches.

example : min_weight="32.1"

new

A boolean value.

example : new="yes"

order

A list of values

Expected values :
  • alpha : alphabetical order on title
  • alpha_reverse : reverse alphabetical order on title
  • created : ascending order on date of content creation
  • created_reverse : descending order on date of content creation
  • given_id : return the same order received in `id` argument which therefore must be set
  • id : order by ascending ID
  • id_reverse : order by descending ID
  • manual : order by ascending position considering a given category. `category` argument must be set
  • manual_reverse : order by ascending position considering a given category. `category` argument must be set
  • max_price : descending price
  • min_price : ascending price
  • new : new products first
  • position : order by ascending position, without considering a parent category
  • position_reverse : order by descending position, without considering a parent category
  • promo : promo products first
  • random : return products in random order
  • ref : alphabetical order on reference
  • ref_reverse : reverse alphabetical order on reference
  • updated : ascending order on date of content update
  • updated_reverse : descending order on date of content update
  • visible : online items firts
  • visible_reverse : offline items first

default : alpha

example : order="category,min_price"

promo

A boolean value.

example : promo="yes"

ref

A single or a list of product references.

example : ref="ref0", id="ref1,ref6"

return_url
Thelia >= 2.3

A boolean value which allows the urls generation.

default : yes

example : return_url="no"

title

filter by title

example : title="foo"

virtual

A boolean value.

example : virtual="yes"

visible

A boolean value.

default : yes

example : visible="no"

with_prev_next_info

A boolean. If set to true, $PREVIOUS and $NEXT output arguments are available.

default : false

example : with_prev_next_info="yes"

Global outputs

Variable Description
$LOOP_COUNT the current results index, starting from 1
$LOOP_TOTAL the total number of results returned by the loop
$CREATE_DATE The creation date of this Product
$UPDATE_DATE The last modification date of this Product

Loop outputs

Variable Description
$BEST_PRICE the product best tax-free price for the received arguments, depending on the attributes and promo status.
$BEST_PRICE_TAX the best price taxes amount
$BEST_TAXED_PRICE the best price including taxes
$BRAND_ID the brand id of this product. Empty if no brand is assigned for this product
$CHAPO the product chapo
$DEFAULT_CATEGORY the default category id associated to this product
$DESCRIPTION the product description
$EAN_CODE Only available if complex='false'
the default product sale elements EAN Code
$HAS_NEXT true if a product exists after this one in the current category, following products positions. Only available if with_prev_next_info parameter is set to true
$HAS_PREVIOUS true if a product exists before this one in the current category, following products positions. Only available if with_prev_next_info parameter is set to true
$ID the product id
$IS_NEW If complex='true'
returns if at least one of it's product sale element is new
If complex='false'
returns if the default product sale element is new
$IS_PROMO If complex='true'
returns if at least one of it's product sale element is in promo
If complex='false'
returns if the default product sale element is in promo
$IS_TRANSLATED check if the product is translated or not
$LOCALE the locale used for this loop
$META_DESCRIPTION the product meta description
$META_KEYWORDS the product meta keywords
$META_TITLE the product meta title
$NEXT The ID of product after this one in the current category, following products positions, or null if none exists. Only available if with_prev_next_info parameter is set to true
$POSITION the product position
$POSTSCRIPTUM the product postscriptum
$PREVIOUS The ID of product before this one in the current category, following products positions, or null if none exists. Only available if with_prev_next_info parameter is set to true
$PRICE Only available if complex='false'
the default product sale elements price
$PRICE_TAX Only available if complex='false'
the default product sale elements price tax
$PRODUCT_SALE_ELEMENT Only available if complex='false'
the default product sale elements id
$PROMO_PRICE Only available if complex='false'
the default product sale elements promo price
$PROMO_PRICE_TAX Only available if complex='false'
the default product sale elements promo price tax
$PSE_COUNT Only available if complex='false'
the number of product sale elements
$QUANTITY Only available if complex='false'
the default product sale elements stock quantity
$REF the product reference
$TAXED_PRICE Only available if complex='false'
the default product sale elements taxed price
$TAXED_PROMO_PRICE Only available if complex='false'
the default product sale elements taxed promo price
$TAX_RULE_ID the product's tax rule ID
$TEMPLATE the template id associated to this product
$TITLE the product title
$URL the product URL
$VIRTUAL Return if the product is a virtual product or not
$VISIBLE Return if the product is visible or not
$WEIGHT Only available if complex='false'
the default product sale elements weight
I want to display all products from categories 1 and 2 and their subcategories whose feature `color` (ID : 1) is `blue` (ID : 13) or `lightblue` (ID : 17), order by ascending price
<ul>
{loop type="product" name="my_product_loop" category="1,2" depth="2" feature_availability="1:13|17" order="min_price"}
    <li>{$TITLE} ({$REF})</li>
{/loop}
</ul>

 

I want to display all products which are in promo for the current category displaying the new products first and then order by decreasing price
<ul>
{loop type="product" name="another_product_loop" promo="true" current_category="true" order="new,max_price"}
    <li>{$TITLE} ({$REF})</li>
{/loop}
</ul>