Hi,
(I will continue in English, it could help other users).
For a feature short delay, the best is to use a custom plugin.
To filter the product categories, the trigger "onBeforeProductUpdate" and "onBeforeProductCreate" are perfect.
So you can use a plugin like this (raw and untested code).
Plugin : hikamarket / categoryexclusion / categoryexclusion.php
<?php
class plgHikamarketCategoryexclusion extends JPlugin [
public function onBeforeProductCreate(&$product, &$do) {
$this->categoryFiltering($product);
}
public function onBeforeProductUpdate(&$product, &$do) {
$this->categoryFiltering($product);
}
public function categoryFiltering(&$product) {
if(empty($product->categories))
return;
$app = JFactory::getApplication();
if($app->isAdmin())
return;
$init = defined('HIKAMARKET_COMPONENT');
if(!$init)
return;
// The excluded categories (hard coded in the plugin but can be read from the plugin configuration with a little more code)
$excluded_categories = array(10, 15, 20);
// Remove the excluded categories
foreach($product->categories as $k => $v) {
if(in_array((int)$v, $excluded_categories))
unset($product->categories[$k]);
}
}
}
Let me know if you have feedback.
Regards,