Jump to content

Product categories on product single view


Recommended Posts

Hello, i'm trying to get the categories id's in product.tpl ...

 

In Product.php, i put these lines in the function getProductProperties

 

  $categories_ids = Product::getProductCategories($row['id_product']);
 $categories_names = array();

 foreach ($categories_ids AS $id) {
  $category = new Category($id);
  $categories_names[] = (int)$id;
 }
 $row['categories'] = $categories_names;

 

When i call from product-list.tpl:

 

<!-- Display categories -->
<span id="product_categories">
{foreach from=$product.categories item=category name=category}

{$category}</br>

{/foreach}
</span>

 

And great, the previous code works; but when i need the product categories in product.tpl, i'm trying with this code and doesn't work:

 

<!-- Display categories -->
<span id="product_categories">
{foreach from=$product->categories item='category' name='category'}
{$category} <br/>
{/foreach}
</span>

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