Jump to content

[SOLVED] [HOWTO] Show Product Tags


Recommended Posts

Hi,

I'm trying to put block tags in product page, but i want to show only the product tags. It is showing the common tags...

How to change that?

Is it also possible to allow user to save their own tags for each product?

Regards

Mozack

Link to comment
Share on other sites

Add the following to product.php before the $smarty->display:

$productTags = Tag::getProductTags($id_product);
$productTags = $productTags[intval($cookie->id_lang)];
$smarty->assign('productTags', $productTags);



This will pass the product's tags into product.tpl. You can then use code like the following to display the tags:

{foreach from=$productTags item=productTag name=productTags}
  {$productTag}{if !$smarty.foreach.productTags.last}, {/if}
{/foreach}

  • Like 1
Link to comment
Share on other sites

  • 5 months later...
  • 3 months later...
Hi,

Please let me know if I want to put product tag in a separate tab (like MORE INFO, COMMENTS) then what should I do.

Thank in advance.


I'd like to know this as well! (for PS 1.4)

Also I need to add a line that says whether the product is downloadable or not!

Thanks!
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Hi, it's similar to the solution posted by "rocky"...

Edited code for product.php has to be placed to the function/method called "process" in the file "controllers/ProductController.php"

$productTags = Tag::getProductTags($this->product->id);
$productTags = $productTags[(int)(self::$cookie->id_lang)];
self::$smarty->assign('productTags', $productTags);

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Hi, it's similar to the solution posted by "rocky"...

Edited code for product.php has to be placed to the function/method called "process" in the file "controllers/ProductController.php"

$productTags = Tag::getProductTags($this->product->id);
$productTags = $productTags[(int)(self::$cookie->id_lang)];
self::$smarty->assign('productTags', $productTags);

 

Thank you very much!

Link to comment
Share on other sites

  • 1 month later...

hello,

thank you very much artizzz, it worked fine!

what can i do if i want to show the tags in the product-list.tpl file?? each product with it's tags.

 

i've tried to insert the code

{if $tags|@count > 0}	  
   {foreach from=$tags item=tag key=name name=tags}
		    <a href="{$link->getPageLink('search.php')}?tag={$tag|urlencode}" >
		    </a> 
   {/foreach}	   
   {/if}

 

inside the <li> in the product-list.tpl file

 

hope i'm explaining myself okay,

thanks in advance

Link to comment
Share on other sites

  • 7 months later...

I tried put product tag instead of product name (title) in product-list.tpl replacing in CategoryController.php :

 

parent::displayContent();
self::$smarty->display(_PS_THEME_DIR_.'category.tpl');

 

to:

parent::displayContent();
$productTags = Tag::getProductTags($this->product->id);
$productTags = $productTags[(int)(self::$cookie->id_lang)];
self::$smarty->assign('productTags', $productTags);
self::$smarty->display(_PS_THEME_DIR_.'category.tpl');

 

 

Then I replace in product-list.tpl :

<h3><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}</a></h3>

 

to:

{foreach from=$productTags item=productTag name=productTags}
<h3><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$productTag}{if !$smarty.foreach.productTags.last}, {/if}</a></h3>
{/foreach}

 

 

AND THIS DON´T WORK

 

Does anybody knows how can I replace the product.name in product-list for product tag?

 

regards

PS 1.4.8

Link to comment
Share on other sites

  • 1 month later...

Hi, Kaloyan_78!

I attached module who displays product tags in product page.

Hope it helped you.

 

Hi, I want to change/translate the phrase: "view similarly tagged products:" which appears with this module. How do I do this?

Thank you!

 

edit: I modified the text in productpagetags.tpl file, but the change doesn't show on the site, no matter how many times I press F5...

Edited by coradyne (see edit history)
Link to comment
Share on other sites

Never mind, apparently it was a cache problem. I learned how to fix it here: http://www.blmodules.com/prestashop-tutorials-users/prestashop-cache-when-modification-do-not-see/#.UJVpuGfjr5t

and to be more precise:

 

 

Delete cache manually is an option, but you will have to delete it each time you make a change.

To make it automatically, please locate to /config/smarty.config.inc.php, find this line:

$smarty->compile_check = false;

and change to:

$smarty->compile_check = true;

Now, your modifications will be refelected immediately.

Link to comment
Share on other sites

  • 7 months later...

it's because in 1.5.4.1 you have to use context object instead of $smarty

if it is possible - please give us information why it doesnt work for you (any error code appear? or sth?)

 

Directly put the companion module Artizzz that does not work, and if I put it by hand, not out absolutely nothing, no error occurs (at least not shown), but nothing comes out.

Link to comment
Share on other sites

okay,

 

so you want exactly the same what mozac wanted?

 

I wanted something like this:

 

View more tags 1

View more tag 2

View more tag 3

....

 

And that is a link to all products with that tag

 

Thanks for everything.

Link to comment
Share on other sites

  • 5 months later...

Hi Vekia, i've a problem with prestashop 1.5.4.1.

I want show product correlate by tag in footer bottom instead of correlate by categories.

I download module posted in previous reply but it doesn't work on my version.

Can u help me? sorry for my english

Link to comment
Share on other sites

  • 3 weeks later...

Thanks for your answer. I tried but it is not working.

 

This is my code:

{foreach from=Tag::getProductTags({$product.id}) key=k item=v}
       	{foreach from=$v item=value}
            <span>{$value|escape:html:'UTF-8'}</span>
        {/foreach}
{/foreach}

it does not output anything.

 

About the sql queries, is there a better approach to do this with less queries?

 

Thanks again.

Link to comment
Share on other sites

  • 1 year later...

This CODE must be work on PRESTASHOP 1.6.1?

 

i need to display TAG, in product-list.tpl... but nothing happend.. HELP pls.

 

i USE

 

Tag::getProductTags({$product.id_product})

 

 

this must be work in PRESTA 1.6? say pls..

Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...
×
×
  • Create New...