Hi,
I see many problems with that code.
1. You already have the equivalent of $categories in $this->categories, so you don't need the code:
$productClass = hikashop_get('class.product');
$categories = $productClass->getCategories($this->element->product_id);
2. The code
$name='';
if(isset($categoryInfo->category_id) && !empty($categoryInfo->category_id)){
$cid = "&cid=".$categoryInfo->category_id;
$name = str_replace(' ','-',strtolower($categoryInfo->category_name));
$name = "&name=".$name;
}
is wrong, you should rather use the alias of the category as in the code I gave you.
3. Instead of manually prepending JURI::base(true) to the non-SEF URL, you should rather use the hikashop_contentLink function like in the code I gave you.
Basically your whole code should be converted to only:
<?php
$bookCat = '';
$writters = '';
foreach($this->categories as $category){
$categoryClass = hikashop_get('class.category');
$categoryClass->addAlias($category);
if($categoryInfo->category_parent_id == '2')
$bookCat .= '<a href="'.hikashop_contentLink('category&task=listing&cid='.$category->category_id.'&name='.$category->alias,$category).'">'.($category->category_name).'</a>';
elseif($categoryInfo->category_parent_id == '2')
$writters .= '<a href="'.hikashop_contentLink('category&task=listing&cid='.$category->category_id.'&name='.$category->alias,$category).'">'.($category->category_name).'</a>';
}
echo "<span class='listCategories'>".$bookCat."</span><br/>";
echo "<span class='listWriters'>".$writters."</span>";
?>
The code in the other thread is more than 4 years old. at that time, the hikashop_contentLink function, the addAlias function or the $this->categories variable didn't existed.