Jump to content
schel4ok

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}        


Share this post


Link to post
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

Share this post


Link to post
Share on other sites

did you just copy+paste my code as it ?
This is only the method to use.
This works for me but the code i gave is only an example ,you may have to adapt it depending on your needs.

Post me your product-list.tpl . I'll modify it for you with a working example.

Share this post


Link to post
Share on other sites

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}


Share this post


Link to post
Share on other sites

Maybe someone can tell or give a clue how to add tags in product-list page? (In prestashop version 1.4.x)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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"}

Share this post


Link to post
Share on other sites

Yes I did it!

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Thank you guys. I am tempted to try this, although I'm not really sure what it does... Will it work on 1.5?

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More