Category image in product page

  • Posts: 99
  • Thank you received: 2
10 years 5 months ago #159908

Hi,
is there a way to show the category image in the product page ?
Or how to retrieve by using a "get" method or a query ?

Thank you!

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

  • Posts: 12953
  • Thank you received: 1778
10 years 5 months ago #159912

Hello,
The solution will be to use a query and to add your code through the "Show_default" file of the "product" view of your front-end template, via "Hikashop->Display->Views".
Checking that thread will probably help you : www.hikashop.com/forum/4-how-to/64957-ca...cts-pages.html#65019

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

  • Posts: 99
  • Thank you received: 2
10 years 5 months ago #160048

Well I manage to find a solution with a raw query and join hoping that indexing of this fields are optimized by hikashop developers,
this solution isn't so smart but it seems to work.

	$db =& JFactory::getDBO();			
	$query = $db->getQuery(true);
	$query->select('*');
	$query->from($db->quoteName('#__hikashop_product_category'));
	$query->join('INNER', $db->quoteName('#__hikashop_category') . ' ON (' . $db->quoteName('#__hikashop_category.category_id') . ' = ' . $db->quoteName('#__hikashop_product_category.category_id') . ')');
	$query->join('LEFT', $db->quoteName('#__hikashop_file') . ' ON (' . $db->quoteName('#__hikashop_file.file_ref_id') . ' = ' . $db->quoteName('#__hikashop_category.category_id') . ')');
	$query->where($db->quoteName('#__hikashop_product_category.product_id')." = ".$db->quote($product_id));	 
	$db->setQuery($query);

	$categories = $db->loadObjectList();
	$cat_image = $this->image->display(@$categories[0]->file_path,true,"",'','', 100, 100);

or

        $category = $db->loadAssoc();
	$cat_image = $this->image->display($category['file_path'],true,"",'','', 100, 100);

I hope that it could be useful also for other users.

Last edit: 10 years 5 months ago by gulp.

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

Time to create page: 0.058 seconds
Powered by Kunena Forum