I m using OC 3.0.3.2
The mod is for show all categories of the product on the product page.
The code is like this:
Twig
Code: Select all
{% if categories %}
{{ text_linked_categories }} <BR><BR>
<div class="catlist">
{% for category in categories %}
<a href="{{ category.href }}">{{ category.name }}</a> <BR>
{% endfor %}
</div>
Code: Select all
$querycats = $this->model_catalog_product->getCategories($product_id);
$categories = array();
foreach( $querycats as $item ) {
$categ = $this->model_catalog_category->getCategory($item['category_id']);
if ($categ['parent_id'] > 0) {
$catinfo['href'] = $this->url->link('product/category', 'path=' . $categ['parent_id'] . '_' . $item['category_id']);
$parentname = $this->model_catalog_category->getCategory($categ['parent_id']);
$categ1['name'] = $parentname['name'];
}
else {
$catinfo['href'] = $this->url->link('product/category', 'path=' . $item['category_id']);
}
$catinfo['name'] = $categ1['name']." >>> ".$categ['name'];
$categories[] = $catinfo;
}
The problem is when I access the product from search page. ( check ps2.png ).
So accessing from search page will result hidden content and I don't not why. If variable will be null at least " >>> " whould appear...
Anyone has any idea?
Thank you!