PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

features or tags on ProductList

33 replies to this topic
#1
kreasta

    PrestaShop Apprentice

  • Members
  • PipPip
  • 44 posts
Hi there, i don't know if i posted in the right category but here it is.

I want to have the product features or the tags in the ProductList after the description.

So. Lets say i have the Iphone as a product. I want to have his features under the description

like: Wifi, Touchscreen, Bluetooth, etc...

In the attachament i put some icons, simbolic to the features.. because i want to make something like
feature_name

or
tag1, tag2, tag3,

Attached Files



#2
Radu

    PrestaShop Addict

  • Moderators
  • 572 posts
in product.php get the feature list or tag list from tables:product_tag, feature_product


in themes/yourtheme/product-list.tpl you can display them

#3
Radu

    PrestaShop Addict

  • Moderators
  • 572 posts
my mistake in Category class you have getProducts - just modify the query to include tags

#4
kreasta

    PrestaShop Apprentice

  • Members
  • PipPip
  • 44 posts
merci radu.

Can you please help me a little bit... i can't pull it off.
i get he error hack attempt when i play in Category.php (from classes)

Can you please tell me what line should i edit, thx

(salutari din bucuresti/greetings from bucharest)

#5
Radu

    PrestaShop Addict

  • Moderators
  • 572 posts
I've needed only one tag in product listing page - but you can manage to get them all - there are more posibilities.

in Category class the new query (the latest added tag):

        $sql = '
SELECT p.*, tg.name as tag_name, pa.`id_product_attribute`, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`, cl.`name` AS category_default, DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new,
(p.price - IF((DATEDIFF(reduction_from, CURDATE()) <= 0 AND DATEDIFF(reduction_to, CURDATE()) >=0) OR reduction_from = reduction_to, IFNULL(reduction_price, (p.price * reduction_percent / 100)),0)) AS orderprice
FROM `'._DB_PREFIX_.'category_product` cp
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.intval($id_lang).')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($id_lang).')
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.intval($id_lang).')
LEFT JOIN `'._DB_PREFIX_.'tax` t ON t.`id_tax` = p.`id_tax`
LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.intval($id_lang).')
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
LEFT JOIN `'._DB_PREFIX_.'tag` tg ON (tg.id_lang='.intval($id_lang).' AND tg.id_tag=(SELECT id_tag FROM product_tag WHERE id_product=p.id_product ORDER BY id_tag DESC LIMIT 1))
WHERE cp.`id_category` = '.intval($this->id).($active ? ' AND p.`active` = 1' : '').'
'.($id_supplier ? 'AND p.id_supplier = '.$id_supplier : '');



in product-list.tpl from themes I've used:
{$product.tag_name}





---------------------------------------------------------------------------------------------------------
However in your case you need all the features/tags (i think it's better using tags because you only need to place some images - there is no need for features that have name/value)

so you can use for each product Tag::getProductTags($product_id); to get all product tags after this line in category.php

$cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay);


#6
roback

    PrestaShop Apprentice

  • Members
  • PipPip
  • 45 posts
I am trying to do a similar thing. I need my feature (Size) to be displayed in the product listing. I modified the product.tpl to move the feature from the data sheet up to right below the short desc. I then tried copying that bit of code:



    {foreach from=$features item=feature}
  • {$feature.name|escape:'htmlall':'UTF-8'} {$feature.value|escape:'htmlall':'UTF-8'}

  • {/foreach}



But it does not display anything.

Reading the above it would seem I need to add something to classes/Products.php, but it is not clear from the above what exactly I have to add.

Also is there a way to get the manufacturer to display right below the Feature on both the product info page and the product listing page? I could not seem to find the variable to include.

Any help would be appreciated.

thanks
Tired of OSCommerce - Hoping PS can rescue me!

#7
eshop2k9

    PrestaShop Newbie

  • Members
  • Pip
  • 23 posts
Hi,

Have you got solution, i am looking for something like this.. I want to display tags in products list page. Please share with me.

Thanks in advance
regards

#8
mohsart

    PrestaShop Addict

  • Members
  • PipPipPip
  • 507 posts
Not sure if this is what you want, but in my shop http://mohsart.se/ I display manufacturer, supplier, and tags (renamed to publisher, book series, and author).
My problem is that the tags appears for each language, apart from that I am very satisfied.

/Mats
I'm on 1.4.3 if nothing else is stated. My blog about using PrestaShop http://mohsart-prest...p.blogspot.com/ (I'm a n00b myself, so much is very basic)

NOTE! When I say "change xxx" I usually mean what is described here

My shop: http://mohsart.se

#9
eshop2k9

    PrestaShop Newbie

  • Members
  • Pip
  • 23 posts
HI

Thanks a lot for your reply. I would like to display tags in product list, please look through attached screen shot.
I have modified query in category.php class file but unable to display tags info. Please someone could help me on this

Attached Files

  • Attached File  tags.jpg   58bytes   1204 downloads


#10
mohsart

    PrestaShop Addict

  • Members
  • PipPipPip
  • 507 posts
This is my code in product.tpl to show the tags when viewing the product:

{if $product->tags}
{l s='Tags'}:
{foreach from=$product->tags item=tag1}
{foreach from=$tag1 item=author}
{$author}
{/foreach}
{/foreach}

{/if}

Maybe entering that or something similar in product-list.tpl will do the trick?

/Mats
I'm on 1.4.3 if nothing else is stated. My blog about using PrestaShop http://mohsart-prest...p.blogspot.com/ (I'm a n00b myself, so much is very basic)

NOTE! When I say "change xxx" I usually mean what is described here

My shop: http://mohsart.se

#11
mohsart

    PrestaShop Addict

  • Members
  • PipPipPip
  • 507 posts
I took a look in the code and the expected (by me) $product.tags doesn't contain the tags, so I don't know...
Is there a way to find out what eg $product contains, for me a not too experienced nor skilled programmer (if I can call me that at all) it would be a great help.

/Mats
I'm on 1.4.3 if nothing else is stated. My blog about using PrestaShop http://mohsart-prest...p.blogspot.com/ (I'm a n00b myself, so much is very basic)

NOTE! When I say "change xxx" I usually mean what is described here

My shop: http://mohsart.se

#12
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
I would use the following code in the PHP file just before assigning the variables to the template:

echo var_dump($products);


The output is plain text and doesn't display well in the browser though. It is best to view the source of the code so you can see the line breaks.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#13
mohsart

    PrestaShop Addict

  • Members
  • PipPipPip
  • 507 posts
Great, thanks rocky
I'm on 1.4.3 if nothing else is stated. My blog about using PrestaShop http://mohsart-prest...p.blogspot.com/ (I'm a n00b myself, so much is very basic)

NOTE! When I say "change xxx" I usually mean what is described here

My shop: http://mohsart.se

#14
mohsart

    PrestaShop Addict

  • Members
  • PipPipPip
  • 507 posts
I keep losing track when looking through the code. :-( A bit similar feeling as when I try to figure out how to show the tags for just one language (in product.tpl)...
I found that in product-list.tpl, $tags holds all the tags (for all products) so maybe one way is to filter out the correct tags from that array. Don't know how to do that though.

/Mats
I'm on 1.4.3 if nothing else is stated. My blog about using PrestaShop http://mohsart-prest...p.blogspot.com/ (I'm a n00b myself, so much is very basic)

NOTE! When I say "change xxx" I usually mean what is described here

My shop: http://mohsart.se

#15
eshop2k9

    PrestaShop Newbie

  • Members
  • Pip
  • 23 posts
mohsart & rocky

Thanks a lot for your efforts. I could not able to figure out how to display tags in products-list.tpl, tried $tags but it did not show anything.

Thanks

#16
mohsart

    PrestaShop Addict

  • Members
  • PipPipPip
  • 507 posts
$tags is an array, look in eg blocktags module for how to see the tags, though as I said I don't know how to filter out the ones associated with the product...

/Mats
I'm on 1.4.3 if nothing else is stated. My blog about using PrestaShop http://mohsart-prest...p.blogspot.com/ (I'm a n00b myself, so much is very basic)

NOTE! When I say "change xxx" I usually mean what is described here

My shop: http://mohsart.se

#17
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
Here's how the tags for the product are set in classes/Product.php:


Tags::getProductTags($id_product);

Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#18
mohsart

    PrestaShop Addict

  • Members
  • PipPipPip
  • 507 posts
Thanks rocky, I'll see if I can figure out how to access it

/Mats
I'm on 1.4.3 if nothing else is stated. My blog about using PrestaShop http://mohsart-prest...p.blogspot.com/ (I'm a n00b myself, so much is very basic)

NOTE! When I say "change xxx" I usually mean what is described here

My shop: http://mohsart.se

#19
eshop2k9

    PrestaShop Newbie

  • Members
  • Pip
  • 23 posts
Hi All

any help on this

Thanks

#20
lafondadebaco

    PrestaShop Apprentice

  • Members
  • PipPip
  • 54 posts
Hi All,

What I made here is to add the array of tags in the list of properties of the product.

To do that go to classes/Product.php, and within the getProductProperties function you should include the following line where the data is stored, about line 2200:

$row['tags'] = Tag::getProductTags($row['id_product']); 


Then all you need to do is to include the following loop of tags into the product-list.tpl:


{if $product.tags}
{foreach from=$product.tags item=tag1}
{foreach from=$tag1 item=tag}


{$tag|escape:'htmlall':'UTF-8'}


{/foreach}
{/foreach}
{/if}


Hope this helps... :D