Variables
Template variables
These variables can be used only in the Templates.
| Variable | Description |
|---|---|
| {{var label.title}} | Label text |
| {{var label.description}} | Label description, can be used as value for title attribute |
| {{var label.url}} | Label URL |
| {{var label.image_url}} | Label's image URL |
| {{var label.image}} | Label's image element with label image as background and with label text |
The {{var label.image}} variable represents a code snippet of the ready-to-use image block with label text. So the value of this variable is a HTML code that uses {{var label.title}} and {{var label.image_url}} inside it and has some predefined inline styles.
The raw value of this variable looks like here:
<div class="label-image" style="background:url({{var label.image}}); background-repeat: no-repeat; width: [image-width]; height: [image-height]; display: flex; justify-content: center; align-items: center; text-align: center">
<span class="label-title">{{var label.title}}</span>
</div>
Where [image-width] and [image-height] are automatically calculated width and height of the image. Those are not variables and can't be used in the HTML template field.
For further styling of the template that uses the {{var label.image}} variable, selectors like div.label-image and span.label-title can be used in the Styles field of the template edit form.
Label variables
These variables can be used only in the Labels.
| Variable | Description |
|---|---|
| [br] | Adds a new line. |
| [price] | Product price. |
| [final_price] | Product final price. |
| [sku] | Product SKU. |
| [stock_qty] | Product's quantity in stock. |
| [discount_amount] | Absolute discount (in store currency). |
| [discount_percent] | Relative discount (in percent). |
| [special_price_dl] | Days left for special price. |
| [new_days] | Days since the product was added to the store or since the date Set product as new from. Returns an empty string if Set product as new to is past. |
| [attr|code] | Value of the product's attribute. Replace code with the actual attribute code. Multiselect attributes return comma-separated values. |
Sales & engagement variables
These variables print the product's real figures, for example [units_sold_30d] sold this month or ★ [rating] · [reviews_count] reviews. In the admin, they are listed in the Sales & Engagement group of the variables list on the label page.
| Variable | Description |
|---|---|
| [units_sold] | Units sold, all time. |
| [units_sold_7d] | Units sold in the last 7 days. |
| [units_sold_30d] | Units sold in the last 30 days. |
| [units_sold_90d] | Units sold in the last 90 days. |
| [views_7d] | Product page views in the last 7 days. |
| [views_30d] | Product page views in the last 30 days. |
| [views_90d] | Product page views in the last 90 days. |
| [reviews_count] | Number of approved reviews, all time. |
| [rating] | Average rating in stars, from 1 to 5 with one decimal (for example, 4.5), all time. |
| [wishlist_count] | Number of wishlists that hold the product, all time. |
The figures are the same ones the Product Popularity conditions use. They are calculated per store view once a day, at 00:30, so each store view prints its own figures. The 7, 30 and 90-day figures cover full days before today. See How popularity figures are calculated for details.
- Empty figures: when a product has no figure (for example, no sales in the period, or no reviews), the variable prints nothing by default. To print
0instead, change the Empty metric value setting in the General settings. - Pair the variable with a condition: to make sure a label never shows without a figure, use the matching Product Popularity condition in the label's rule. For example, use Units Sold, Last 30 Days, is greater than 0 for a label that prints
[units_sold_30d]. - Views: view figures need Magento Reports enabled. See How popularity figures are calculated.
When the figures are recalculated, the cached pages of products that show a sales & engagement variable are cleaned, so they print the new figures. If a full label reindex is running at that moment, the cache is not cleaned and the pages show the new figures after the next daily run.
If your catalog has a product attribute with the same code as one of these variables (for example, rating), the variable now prints the sales & engagement figure. To print the attribute value, use [attr|rating] instead.