Display categories in product page

  • Posts: 95
  • Thank you received: 1
  • Hikashop Business
11 years 6 months ago #134222

Hi,
I recently bought hikashop business and i have one question .
I want to display product categories in the product page. I managed to do that with $this->categories where i can get the name of the categories. But how can i get the url to each category and the photo of each category? Thank you in advance

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 6 months ago #134299

Hi,

You can ue that coed in the "product / show_default" view to have all the categories informations:

$productClass = hikashop_get('class.product');
$categoryIds = $productClass->getCategories($this->element->product_id);
$db = JFactory::getDBO();
$categories = array();
foreach($categoryIds as $k => $category){
	$categories[$category] = new stdClass();
	$db->setQuery('SELECT * FROM '.hikashop_table('category').' WHERE `category_id` = '.$category);
	$categories[$category] = $db->loadObject();
	$db->setQuery('SELECT * FROM '.hikashop_table('file').' WHERE `file_ref_id` = '.$category);
	$categories[$category]->image = $db->loadObject();
}
All is in the var $categories.

Regarding the url to each category, there is no default url, you have to create a menu listing the categories.
Then create dynamically the urls depending on the previously created menu.

Please Log in or Create an account to join the conversation.

Time to create page: 0.067 seconds
Powered by Kunena Forum