How to show Product Categories under Products

  • Posts: 5
  • Thank you received: 1
7 years 3 months ago #287400

-- HikaShop version -- : 3.2.2
-- Joomla version -- : 3.8.3

Is there a way to show the related product categories underneath products, the same way Related products can be shown as per the tutorial, but display related categories instead?

For example. If we were creating football kits, the user goes onto a particular Football Shirt product page, and underneath it shows the related categories of Football Shorts and Football Socks?

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

  • Posts: 83778
  • Thank you received: 13565
  • MODERATOR
7 years 3 months ago #287407

Hi,

There is no such system.
You could create a custom product field to enter that information in the products, configure a module under the product page to display all the categories of the shop, and then write a small plugin implementing the "onBeforeCategoryListingLoad" trigger of HikaShop to filter out the categories so that it only displays the ones selected in the current product.
www.hikashop.com/support/documentation/6...eCategoryListingLoad
So if you're a developer or hire one to develop the plugin, it's totally possible.

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

  • Posts: 5
  • Thank you received: 1
7 years 3 months ago #287590

Hi nicolas

Thanks for your help. I've followed your instructions so far and got all of the categories sitting underneath the product which is great. I'm keen to understand myself how to implement the onBeforeCategoryListingLoad(&$filters) function to filter out the categories but can't seem to grasp what the HikaSHop development documention you linked is saying. Do you have any examples of the onBeforeCategoryListingLoad(&$filters) function being used so I can use as an example?

Grateful for any help

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

  • Posts: 83778
  • Thank you received: 13565
  • MODERATOR
7 years 3 months ago #287591

Hi,

For example, something like that:

function onBeforeCategoryListingLoad( &$filters, &$order, &$parentObject, &$leftjoin){
 if(@$_REQUEST['ctrl'] == 'product' && @$_REQUEST['task'] == 'show' ){
  $product_id = $_REQUEST['cid'];
  $productClass = hikashop_get('class.product');
  $categories = $productClass->getCategories($product_id);
  $filters[] = 'category_id IN ('.implode(',', $categories).' )';
 }
}

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

Time to create page: 0.059 seconds
Powered by Kunena Forum