Jump to content

Product reference in product list prestashop 1.6


Recommended Posts

Hello all,

 

I am trying to add the product reference in th product listing, below the product name. I was reading lots of posts and it seems to be easier in older ps versions but I am facing a problem when trying to add it.

 

Adding {$product.reference} into the product-list.tpl don´t work in this ps version.

 

I managed to add the reference into the product-list by adding the following code to the product-list.tpl:

<p id="product_reference"{if empty($product->reference) || !$product->reference} style="display: none;"{/if}>
<label>{l s='Model'} </label>
<span class="editable" itemprop="sku">{$product.reference} </span>
</p>

The problem is when changing the view from grid to list. It changes to "undefined"

 

I used the following code into the global.js (the one that manages the switch):

html += '<p id="product_reference">'+ $(element).find('.product_reference').html() + '</p>';

I know the problem is here in the global.js but as I don´t have idea of this lenguaje I can´t find out how to make it work.

 

Hope I was clear, and please advise if someone knows how to do this

 

Thanks!

Link to comment
Share on other sites

you use ($product->reference) in if codition and {$product.reference} in <span>

product-list.tpl doesnt contain $product as object, just a $product as an array

so you have to use this variable as array

 

use $product.reference only

Link to comment
Share on other sites

Vekia. I don´t want to keep on bothering you but it still disappears when switching from grid to list.

 

I left the product-list.tpl like this:

<p id="product_reference"{if empty($product.reference) || !$product.reference} style="display: none;"{/if}>
<label>{l s='Model'} </label>
<span class="editable" itemprop="sku">{$product.reference} </span>
</p>

The product reference ppears correctly but then it disappears.

Link to comment
Share on other sites

Any ideas?

 

I left the product list.tpl

<p id="product_reference"{if empty($product.reference) || !$product.reference} style="display: none;"{/if}>
<label>{l s='Model'} </label>
<span class="editable" itemprop="sku">{$product.reference} </span>
</p>

and the global.js

html += '<p id="product_reference">'+ $(element).find('.product_reference').html() + '</p>';
  • Like 1
Link to comment
Share on other sites

In product-list.tpl:

<h5 itemprop="name">
        {if isset($product.pack_quantity) && $product.pack_quantity}{$product.pack_quantity|intval|cat:' x '}{/if}
        <a class="product-name" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url">
							{$product.name|truncate:45:'...'|escape:'html':'UTF-8'}
	</a>
	<p id="product_reference"{if empty($product.reference) || !$product.reference} style="display: none;"{/if}>
        <label>{l s='Model'} </label>
	<span class="editable" itemprop="sku">{$product.reference}</span>
        </p>
</h5>

And it shows right after the Product name. 

 

Try it and let me know.

  • Like 2
Link to comment
Share on other sites

×
×
  • Create New...