Product List Front-End Guide

Product Lists allow you to create a dynamic product list and display it on any page of your store.

This article explains how to implement a Product List in your Store's Front-end Templates and describes the data available to you when using it.

Smarty Function

In order to use the Smarty Tag, you must first retrieve the list into a Smarty Variable, which you save as an Array of Products. This array can then be used in a loop, like the example below:

{product_list type_list=Mixed limit=7 product_id=12043 product_list_type=related  recommendations="related_recommendations" }

{foreach from = $related_recommendations item=related}

	{$related.product_filename}


{/foreach}

Accepted Parameters

ParameterExampleRequiredExplanation
type_listmanual | generated | mixedY/NWhich products must be shown in the Product list. This parameter is mandatory for Cross Sell/Upsell/Related, but will be ignored by Generic lists, as there are no Manual entries for Generic lists - only Generated lists will be shown in this case.

There are 3 types:

manual: The list of products includes only those entered manually into the Products > Cross Sell/Upsell/Related tabs.
generated: The list of products returned is generated by the filters only.
* mixed: The list of products will include both the manual and dynamically generated ones. Manually specified products will appear at the top of the list.
limit20YThe quantity of products that will be shown for the list. The Maximum number for Cross Sell/Upsell/Related lists is 20 and there is no limit for Generic lists.
offset20NInitial position of the list. 20 means "take products after the 20th product in the list"
product_id1234Y/NWhich product will be used as the "Currently viewed" product. This field is only mandatory for Cross Sell/Upsell/Related lists and is ignored by Generic lists.
product_list_typegenericYWhich type of list to show. Options available are:

generic
upsell
cross sell
related
product_list_nameBest SellersYThe field is mandatory for all lists
minimum4NMinimum number of products to display. If less than this number of products are available in the list then the component is not displayed.
template"product/product_list_template.tpl.html"NUse a template file saved into front-end templates folder. The output parameter "recommendations" will set an array that will contain all the products for this Product List and it can be used inside the template.
recommendationsrecent_productsYThis is the name of the variable you would like the results of your query placed in. For example, if you set this to "recent_products" then the items returned by this method will be loaded into a $recent_products template variable.

Data Returned

FieldValuesDescription
[ item ].xArray( product )The data returned by this function is saved to the variable named in the recommendations parameter.

This data takes the form of an array of content_category (as described further down in this table).
productContainerA container holding all of the product details.

For more details regarding the contents of this container, please see the $product declarations in the Product Details support article.

Please see the fields detailed below in this support article for information regarding some extra fields, that are only available in the $product variable from within the Product Lists' return data.
product.fieldsArrayA Name/Value pair array of field names and values pulled from the Product's Additional Fields data, e.g. Brand, Colour, or anything else configured in the Fields section of any products Edit page.
products.trackingStringThis is the tracking code that has been configured for the product in question and is typically used whenever the product is displayed for tracking purposes, e.g. perhaps for Google Analytics.

See more about tracking below in this document.
product.price_promotionsArrayThis is an Indexed Array (as defined below) of any Product Price Promotion applicable to the current product.
product.price_promotions.x.promotion_idPositive IntegerThe Internal ID Aurora uses to identify a Product Price Promotion.
product.price_promotions.x.promotion_product_textStringThis is the text that is configured for use on the Product Details page/section of your Store.
product.price_promotions.x.promotion_product_listing_textStringThis is the text that is configured for use on the Product Category/Listing pages/sections of your Store.
product.price_promotions.x.start_dateContainer
product.price_promotions.x.start_date.date_to_runTimestamp (2015-11-08 00:00:00)This is the date the Price Promotion was applied.
product.price_promotions.x.end_dateContainer
product.price_promotions.x.end_date.date_to_runTimestamp (2015-11-08 00:00:00)This is the date the Price Promotion will expire.

Example using template

The code below shows an example of the Smarty Function using templates

{product_list type_list=Mixed limit=7 product_id=12043 product_list_type=related  recommendations="products_returned" template="products/product_list_recommendation.tpl.html"}

And the file products/product_list_recommendation.tpl.html could be similar to the example below:

           <div id="relateditems">
                <ul>
                    {foreach from=$products_returned item="product"}
                    <li>
                        <a href="{$product.product_filename}">{$product.product_name}</a>
                    </li>
                    {/foreach}
                </ul>
              </div>

Recommendation data

The Product Lists data can be retrieved by an Ajax request using the same parameters as Smarty.  The result is a list of products in JSON format.

$.ajax({url: '/ajax/Ajax_Products_Lists/getListProducts',
data: {   
    "type_list": 'mixed',
    "limit": 20,
    "offset": null,
    "product_id": null,
    "product_list_type": 'generic',
    "product_list_name": 'Generic List',
    "minimum_limit": null
},
dataType: 'json',
success:function(data) {
    console.log(data);
}
});

Tracking code

The products returned by a Product List result will provide a Google Event Tracking Code that can be used in your store.

The signature of a Google Tracking code for a Product that comes from a Product List is as followed:

_trackEvent(Product List name, action, Product Name, Product Id)

One example of a Google Event Tracking code that comes from a Product List could be:

_gaq.push(['_trackEvent', 'Upsell Category Example', 'click', 'A product Name', '45'])

Once you have the Google Tracking library in your store (ga.js), you can use the code above.  You can test the tracking prior to use the Google Tracking code, using the code below as a debugger:

  	var _gaq = _gaq || [];
	_gaq.push = function (){
		for (var i = 0; i < arguments.length; i++) {
		    alert(arguments[i]);
		}
	}

Custom Tracking

Product Lists provide Product details that could be used to create a custom Tracking code for other services.  You can just use the result and create a new code manually:

{foreach from=$products_returned item="product"}
<button type="button" onclick="customTracking({$product.id}, {$product.name})" >Test Tracking</button>
{/foreach}