get_products_parent_categories

Overview

This function finds the 'deepest' category to which the specified product belongs to, and then returns all Categories from the same level as this categories parent. For example, if the lowest category was Men's > Men's T-Shirts > Latest Fashion > Cool Trends, it would look for Cool Trends, go up to Latest Fashion and find all other categories on the same level as Latest Fashion.

Accepted Parameters

ParameterValuesDefaultDescriptionRequiredSample
product_idPositive IntegerThe Internal ID Aurora uses to identify a Product.Yes1
limitPositive Integer5The number of product categories to return in this request.No5
parent_categoriesComma separated stringsIf you want to force the categories to be from specific parent categories, e.g only return categories that have a parent category of "Mens"Nomens

Data Returned

FieldValuesDescription
product_countNumericThe total number of products within this category that are enabled and have stock, or are allocated to a Stock Action on Zero that allows out of stock products to appear.
category_nameStringThe name of the category.
category_complete_urlStringThe full URL of the category.

Example template code

You can add the following to the product details page:  

{get_products_parent_categories limit="5" item="smarty_function_get_product_categories" id=$product.id}
{foreach from = $smarty_function_get_product_categories item=parent_category}
  <a href="/{$parent_category.category_complete_url}/">{$parent_category.category_name}</a>
{/foreach}