Jump to content

[ solved ] Categories of product on product-list.tpl page


radus

Recommended Posts

Hello,

 

On product-list.tpl , i need to show all categories where a product is. I tried VEKIA's solution

 

{foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat}

 

<meta itemprop="name" content="{$cat.name}" />

 

<meta itemprop="url" content="{$link->getCategoryLink({$cat.id_category})}" />

 

{/foreach}

 

for Product-list.TPL it is not working.

 

Anybody knows why ?

 

PS 1.5.6.2

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

 

Hello,

 

On product-list.tpl , i need to show all categories where a product is. I tried VEKIA's solution 

 

                 {foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat}
 
                    <meta itemprop="name" content="{$cat.name}" />
 
                    <meta itemprop="url" content="{$link->getCategoryLink({$cat.id_category})}" />
 
                 {/foreach}
 
for Product-list.TPL it is not working.
 
Anybody knows why ?
 
PS 1.5.6.2

 

 

this code is for product page.

to use it in product listings, like category view you have to use product id variable instead of tools::getValue function

 

 

something like:

                {foreach from=Product::getProductCategoriesFull($product.id) item=cat}
 
                    <meta itemprop="name" content="{$cat.name}" />
 
                    <meta itemprop="url" content="{$link->getCategoryLink({$cat.id_category})}" />
 
                 {/foreach}
  • Like 1
Link to comment
Share on other sites

Thankx VEKIA, works ferfect.

 

I implemented

 

                    {foreach from=Product::getProductCategoriesFull($product.id_product) item=category}
 
                     <div itemprop="category" itemscope itemtype="http://schema.org/Product">
 
                         <meta itemprop="name" content="{$category.name|escape:'html':'UTF-8'}" />
 
                         <meta itemprop="url" content="{$link->getCategoryLink($category.id_category, $category.link_rewrite)|escape:'html':'UTF-8'}" />
 
                     </div>
             
                    {/foreach}
Link to comment
Share on other sites

  • 4 months later...

 

Thankx VEKIA, works ferfect.

 

I implemented

 

                    {foreach from=Product::getProductCategoriesFull($product.id_product) item=category}
 
                     <div itemprop="category" itemscope itemtype="http://schema.org/Product">
 
                         <meta itemprop="name" content="{$category.name|escape:'html':'UTF-8'}" />
 
                         <meta itemprop="url" content="{$link->getCategoryLink($category.id_category, $category.link_rewrite)|escape:'html':'UTF-8'}" />
 
                     </div>
             
                    {/foreach}

 

 

Hello, I tried this on presta 1.6.0.9 but not work for me, I guess that for 1.6 the code need some modifications, but I dont have any idea what...

 

Someone?

  • Like 1
Link to comment
Share on other sites

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...