Beginerforever Posted March 31, 2016 Share Posted March 31, 2016 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 More sharing options...
roja45 Posted March 31, 2016 Share Posted March 31, 2016 $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 More sharing options...
Beginerforever Posted March 31, 2016 Author Share Posted March 31, 2016 Hi, Thank you for the advice ! It works very well now ! Now I will make my css style. Link to comment Share on other sites More sharing options...
rjps Posted September 25, 2016 Share Posted September 25, 2016 Thanks Roja45. It works! Can any one suggest code to put only a specific product feature. Not all of them. Thanks! Link to comment Share on other sites More sharing options...
fedotv Posted November 11, 2016 Share Posted November 11, 2016 (edited) here you have it rjps: {if isset($product.features)} <div class="features"> {foreach from=$product.features item=feature} <div> {if $feature.name == 'featureName'} {$feature.name}: <span>{$feature.value}</span> {/if} </div> {/foreach} </div> {/if} Edited November 11, 2016 by fedotv (see edit history) 1 Link to comment Share on other sites More sharing options...
rjps Posted November 24, 2016 Share Posted November 24, 2016 Thanks fedotv! It works. But only if i make the condition with feature id. No success with future name. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now