-- HikaShop version -- : 4.0.1
Hi
Hikashop allow a product to be displayed in all categories, even if the product is not published in more than one category.
I would like to prevent this, so I'm looking to modify the product/show_default.php file.
I can get an array of the categories, the product belong to with this code:
$productClass = hikashop_get('class.product');
$categories = $productClass->getCategories($this->element->product_id);
My problem is finding the category that I'm currently "in". The best way I could come up with, is access the active menu items hikashop parameters, like this:
// Using current menu item to find current hika category params
$app = JFactory::getApplication();
$currentMenuItem = $app->getMenu()->getActive();
$params = $currentMenuItem->params;
$currentCategory = $params->get('hk_category')->category;
// Check if product is published in current hika category
$productClass = hikashop_get('class.product');
// $displayProduct now contains a boolean value we can test with
$displayProduct = array_key_exists($currentCategory, $this->categories);
Can you see a better way to solve this ??
Thanks