Jump to content

[Q] How to display features on product list ? Prestashop 1.6.3


Beginerforever

Recommended Posts

Hi everyone !

 

Hope everyone's good :) (cause after that, I don't know if you're going to be ;)).

 

Everything is in the topic.

 

I followed the 2 links :

https://www.prestashop.com/forums/topic/318019-display-features-in-product-list-product-page/

http://nemops.com/features-to-product-list-prestashop-16/#.Uzpyr_na6r1

 

I added the following code in my product-list.tpl

{if isset($product->features)}
 <div class="features">
  {foreach from=$product->features item=feature}
    <div>
     {$feature.name|escape:'html':'UTF-8'}: <span>{$feature.value|escape:'html':'UTF-8'}</span>
    </div>
  {/foreach}
 </div>
{/if}

Now I have this after adding the code

<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>
</h5>
								
{if isset($product->features)}
 <div class="features">
  {foreach from=$product->features item=feature}
    <div>
     {$feature.name|escape:'html':'UTF-8'}: <span>{$feature.value|escape:'html':'UTF-8'}</span>
    </div>
  {/foreach}
 </div>
{/if}
						 		
{capture name='displayProductListReviews'}{hook h='displayProductListReviews' product=$product}{/capture}

I also added this code into global.js

html += '<div class="features">'+ $(element).find('.features').html() + '</div>';

After adding the code, I have this at both LIST and GRID view

html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>';						
html += '<div class="features">'+ $(element).find('.features').html() + '</div>';

Unfortunately (yes I know) I only have a 'undefined' at my features place in the product list. And moreover this 'undefined' label don't show up if I don't click on the List view, I need first to click on the grid view to make the label 'undefined' appear then switch to the Grid view.

 

I looked over the Web but nothing helped me.

Maybe someone here can help a little newbie in the Prestashop World. I'll be very grateful to you.

Link to comment
Share on other sites

$product is an array not an object.

 

change the block in the tpl to this  (. not ->)

{if isset($product.features)}
<div class="features">
{foreach from=$product.features item=feature}
<div>
{$feature.name|escape:'html':'UTF-8'}: <span>{$feature.value|escape:'html':'UTF-8'}</span>
</div>
{/foreach}
</div>
{/if}
Link to comment
Share on other sites

  • 5 months later...
  • 1 month later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...