Jump to content

Display all categories to which product belongs on its product page - with "getProductcategories"


Recommended Posts

Hi all of you,

 

I am desperately trying to have all product categories as links displayed on my product page.

It would look as on this page where you can read "Found in: Gadgets & Tools ....."

 

I have found the function "getProductCategories" which should be the right one. The thing is i don't know how to make it work through the product.php, product.tpl and productcontroller.php.

 

I thank you in advance for any help on that topic.

Link to comment
Share on other sites

Do not touch product.php or productcontroller.php. The information you require is already passed to product.tpl. You can do something like the following at the location you want output displayed in product.tpl:

 

<p>This product appears in:
{foreach $categories as $category}
	 <a href="{$category['link_rewrite']}">{$category['name']}</a>{if !$category@last} |{/if}	
{/foreach}</p>

Edited by phrasespot (see edit history)
  • Like 1
Link to comment
Share on other sites

Ok, I am using version PrestaShop™ 1.4.7.

 

I may have a solution which is on that page, i have tested it:

http://www.prestashop.com/forums/topic/139200-display-categories-to-which-product-belongs-in-product-detail-page/page__p__816472#entry816472

 

It works (by the way, I did took off all the scripts from it to test your solution).

 

That one unfortunately only display categories as name, ca you maybe help me to have it displayed as links ?

 

Thanks for your help

Link to comment
Share on other sites

Well it worked but now i get problems on other pages ...

Then your theme (or some 3rd party modules you use) must be incompatible with Smarty 3. No matter. change the snippet I posted to following (using Smarty 2 syntax):

<p>This product appears in:
{foreach item=cat name=cats from=$categories}
<a href="{$cat.link_rewrite}">{$cat.name}</a>{if !$smarty.foreach.cats.last} |{/if}
{/foreach}</p>

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

  • 7 months later...
  • 4 months later...

<p>This product appears in:
	{foreach $categories as $category}
			 <a href="{$category['link_rewrite']}">{$category['name']}</a>{if !$category@last} |{/if}	
	{/foreach}</p>

 

Phrasespot, this displays all categories that exist in your shop. It does not display the categories that a product belongs to. Just an FYI. Still a useful peice of code.

Edited by threeopus3 (see edit history)
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...