Jump to content

features in category page (product-list)


Recommended Posts

Hi, did you find it ?
Here is how i did it in product-list.tpl :

A little php code inside smarty

            
getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" />
{if $product.new == 1}{l s='new'}{/if}{$product.name|escape:'htmlall':'UTF-8'|truncate:80:'...'}


                
                   Signé {$product.manufacturer_name}

                   {$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}
                   <!-- product's features -->
                       {php}
                           global $cookie;
                           $product=$this->get_template_vars('product'); // nb $this IS smarty
                           $myprod = new Product($product['id_product']);
                           $features = $myprod->getFrontFeatures(intval($cookie->id_lang));
                           $this->assign('features',$features);
                       {/php}
                       {if $features}
                           {foreach from=$features item=feature}
                                                        THERE WAHTEVER YOU NEED TO DISPLAY ABOUT FEATURES EX: {$feature.value|escape:'htmlall':'UTF-8'}
                           {/foreach}
                       {/if}        


Link to comment
Share on other sites

I'm not good in smarty, but your code is not working.

                    <!-- product's features -->
                       {php}
                           global $cookie;
                           $product=$this->get_template_vars('product'); // nb $this IS smarty
                           $myprod = new Product($product['id_product']);
                           $features = $myprod->getFrontFeatures(intval($cookie->id_lang));
                           $this->assign('features',$features);
                       {/php}
                       {if $features}
                           {foreach from=$features item=feature}
                                                        THERE WAHTEVER YOU NEED TO DISPLAY ABOUT FEATURES EX: {$feature.value|escape:'htmlall':'UTF-8'}
                           {/foreach}
                       {/if}  




I copied it inside

and it brakes my category page. You can see difference on 2 attached screenshots:
screenshot.13.jpg - normal category view
screenshot.11.jpg - after inserting your code

40307_j1zakOGsnHJ2qQDHFrKN_t

40308_0CqumpTDiKsQNI2t2hwr_t

Link to comment
Share on other sites

  • 1 month later...

Shel...

Could you add the features to my product-list file?

Im running 1.3.6.0

>
{if isset($products)}
   <!-- Products list -->
</pre>
<ul>
   {foreach from=$products item=product name=products}


           {if $product.on_sale} 




               {elseif ($product.reduction_price != 0 || $product.reduction_percent != 0) && ($product.reduction_from == $product.reduction_to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $product.reduction_to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $product.reduction_from))}

               {/if}


getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" width="{$homeSize.width}" height="{$homeSize.height}" />{if $product.new == 1}{l s='new'}{/if}
{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}

{$product.description_short|truncate:150:'...'|strip_tags:'UTF-8'}
                                                                                 



{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc} {/if} {l s='tax incl.'}

{convertPrice price=$product.price_tax_exc} {l s='tax excl.'} 
{if ($product.allow_oosp OR $product.quantity > 0)}{l s='Available'}{else}{l s='Out of stock'}{/if}

               {if ($product.allow_oosp OR $product.quantity > 0) && $product.customizable != 2}

               {else}
{l s='Add to cart'}
               {/if}



   {/foreach}

   <!-- /Products list -->
{/if}


Link to comment
Share on other sites

  • 4 weeks later...

Hi... for prestashop 1.4, in product-list.tpl you cannot use:

>
{if $features}
       <!-- product's features -->
</pre>
<ul>
       {foreach from=$features item=feature}
{$feature.name|escape:'htmlall':'UTF-8'} {$feature.value|escape:'htmlall':'UTF-8}
       {/foreach}
</ul>
<br>{/if}



replace with:

>
</pre>
<ul>
{foreach from=$product.features item=feature name=features}         
{$feature.name|escape:'htmlall':'UTF-8'} {$feature.value|escape:'htmlall':'UTF-8'}
{/foreach}
               </ul>



happy coding :)

  • Like 1
Link to comment
Share on other sites

this works. thanks


you're welcome... btw if you know something about integrated paypal payment (third party modules or default available modules) please help me at: http://www.prestashop.com/forums/viewthread/113729/

or if you know something about gift certificate module, please help at: http://www.prestashop.com/forums/viewthread/112393/

Thanks a lot
Link to comment
Share on other sites

  • 2 weeks later...

Great!
But produts can have a lot of features, let say 20.
In this case it is needed to show only few of them.
Is it possible to choose which features we will show on product list page?

like this

{foreach from=$product.features item=feature name=features where $feature.name = "power" & $feature.name = "air flow" & $feature.name = "room area"}

Link to comment
Share on other sites

  • 8 months later...

How do you find out the id of your required feature? which table in the database do you refer to?

 

I really need to display one of my features on the product-list.tpl page but the code above gives me the incorrect feature.

 

Please help going around in circles trying to solve it!

 

Thanks

 

Lee

Link to comment
Share on other sites

  • 2 months later...

How do you find out the id of your required feature? which table in the database do you refer to?

 

I really need to display one of my features on the product-list.tpl page but the code above gives me the incorrect feature.

 

Please help going around in circles trying to solve it!

 

Thanks

 

Lee

 

Hi,

 

ID of feature is in ps_feature and the name that belongs to ID is in ps_feature_lang. Code dosent work because there is nothing inside <if> so the condition cant work

 

this is working code:

 

<!-- product's features -->
{if $product.features}
{foreach from=$product.features item=feature name=features} 
{if $feature.id_feature == 8 OR $feature.id_feature == 9 }
<span class="feture">{$feature.name|escape:'htmlall':'UTF-8'}: {$feature.value|escape:'htmlall':'UTF-8'}</span>
{/if}					
{/foreach}

{/if}	   
<!-- product's features -->

  • Like 1
Link to comment
Share on other sites

  • 6 months later...
  • 1 month later...
  • 1 year later...
  • 3 months later...

Hi,

 

ID of feature is in ps_feature and the name that belongs to ID is in ps_feature_lang. Code dosent work because there is nothing inside <if> so the condition cant work

 

this is working code:

 

<!-- product's features -->
{if $product.features}
{foreach from=$product.features item=feature name=features} 
{if $feature.id_feature == 8 OR $feature.id_feature == 9 }
<span class="feture">{$feature.name|escape:'htmlall':'UTF-8'}: {$feature.value|escape:'htmlall':'UTF-8'}</span>
{/if}					
{/foreach}
 
{/if}	   
<!-- product's features -->

 

Thanks for this info...

I also was trying to find the way to get the features by ID without luck until found your post!

Link to comment
Share on other sites

  • 1 year later...

Hi... for prestashop 1.4, in product-list.tpl you cannot use:

{if $features}        <!-- product's features -->        <ul>        {foreach from=$features item=feature}            <li><span>{$feature.name|escape:'htmlall':'UTF-8'}</span> {$feature.value|escape:'htmlall':'UTF-8}</li>        {/foreach}        </ul>{/if}

replace with:

<ul>{foreach from=$product.features item=feature name=features}         <li><span>{$feature.name|escape:'htmlall':'UTF-8'}</span> {$feature.value|escape:'htmlall':'UTF-8'}</li>               {/foreach}</ul>

happy coding :)

 

I used this in 1.6 in product-list.tpl and it worked perfectly.  Thank you so much.  

 

I placed it below

{$product.name|truncate:45:'...'|escape:'html':'UTF-8'}

</a>                  

 

 Steve

Link to comment
Share on other sites

  • 1 year 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...