Product Functions
The Products and all of their content is accessible using a small family of Smarty functions.
This article offers a brief overview of the functions available in the Aurora front-end for accessing the Product data and how to use them.
Introduction
The products configured in Aurora can be accessed using a range of simple Smarty Functions designed to allow you to insert product details, links, and images wherever you need them in the Aurora front-end.
Product Details (get_product_details)
You are able to fetch all of the data detailed in the Product Details support article using this function.
For more detail regarding the data returned by this function, please refer to the Product Details support article.
Accepted Parameters
Parameter | Value | Default | Description | Required |
---|---|---|---|---|
item | String | "product_details" | The name of the Smart Template Variable into which you would like to load the data being requested. | No |
id | Integer | The Internal ID Aurora uses to identify a Product. | One of reference or id must be provided. | |
reference | String | The unique Product Reference set against a Product (this is usually the product SKU). | One of reference or id must be provided. |
Data Returned
Field | Values | Description |
---|---|---|
[ item ].x | Array( product_details ) | The data returned by this function is saved to the variable named in the item parameter. For more detail regarding the data returned by this function, please refer to the Product Details support article. |
Example template code
{get_product_details reference="sku0001"}
<h2>{$product_details.product_name}</h2>
<div>{$product_details.product_description}</div>
{get_product_details id="12345" item="our_custom_product"}
<h2>{$our_custom_product.product_name}</h2>
<div>{$our_custom_product.product_description}</div>
Product Additional Field Values (get_product_field_values)
Example Aurora Template: templates/example.com/products/grouped-product-swatches.tpl.html
You are able to fetch all of the values for any one product field using the get_product_field_values function.
Accepted Parameters
Parameter | Value | Default | Description | Required |
---|---|---|---|---|
item | String | "product_field_values" | The name of the Smarty Template Variable into which you would like to load the data being requested. | No |
product_id | Integer | The Internal ID Aurora used to identify a Product. | One of reference or product_id must be provided. | |
reference | String | The unique Product Reference set against a Product (this is usually the product SKU). | One of reference or product_**id** must be provided. | |
field_name | String | The name of the Product Additional Field for which the values should be returned. Field names are not cases sensitive. | Yes |
Data Returned
Field | Values | Description |
---|---|---|
[item] | String | The data returned by this function is saved to the variable named in the item parameter. If the product has multiple values for a requested field, then they are returned as a pipe-delimited string, e.g. a product that is blue would return "Blue" for the "Colour" field, but one that is Blue and Red would return "Blue|Red". The field values are organised alphabetically before being joined by the pipe character. |
Example template code
{get_product_field_values reference="sku0001" field_name="Colour"}
<h2>{$product_field_values}</h2>
{get_product_field_values product_id="12345" field_name="Brand" item="our_custom_product_field_value"}
<h2>{$our_custom_product_field_value}</h2>
Product URLs (get_product_url)
Example Aurora Template: templates/example.com/products/grouped-product-swatches.tpl.html
You are able to fetch the relative URL for any one product using the get_product_url function.
Accepted Parameters
Parameter | Value | Default | Description | Required |
---|---|---|---|---|
id | Integer | The Internal ID Aurora uses to identify a Product. | One of reference or id must be provided. | |
reference | String | The unique Product Reference set against a Product (this is usually the product SKU). | One of reference or id must be provided. |
Data Returned
This function does not return any data as such, instead it simply outputs the URL requested to the template.
Example template code
<a href="{get_product_url id=$product.id}">Product Details</a>
<a href="{get_product_url reference=$product.product_reference}">Product Details</a>
Product Media (get_product_media)
You can fetch all the data for product media using the get_product_media function.
Accepted Parameters
Parameter | Value | Default | Description | Required |
---|---|---|---|---|
item | String | "product_media" | The name of the Smarty Template Variable into which you would like to load the data being requested. | No |
product_id | Integer | The Internal ID Aurora uses to identify a Product. | Yes. If only product_id is provided it will return all linked media files for said product. | |
image_label | String | The image label, used to identify the file. | Optional. Cannot have image_label and image_name. | |
image_name | String | The image filename, used to identify the file. | Optional. Cannot have image_label and image_name. |
Data Returned
Field | Values | Description |
---|---|---|
[ item ].x | Array | An array of 'item' (see below). If no 'item' parameter is defined in the call to get_product_media this will be exposed to the Template as $product_media. |
item.filename | String | Path to the file. |
item.type | [ Image | Video | Document ] | This describes what type of media Aurora considers the file to contain. |
item.label | String | The Label assigned to the file for the product in question (if there is one). |
Example template code
{get_product_media product_id=32221}
{foreach from = $product_media item=related_media}
{$related_media.filename}
{/foreach}
Updated over 2 years ago