Hello everyone,
I am trying to exclude specific products according to usergroup_id… Thus, I have this code in my func.php
file (inside addon my_changes, this is a PHP hook get_products_pre
from fn_get_products(..)
):
function fn_my_changes_get_products_pre($params, $items_per_page, $lang_code) {
$auth = & Tygh::$app['session']['auth'];
if (in_array(32,$auth['usergroup_ids'])) {
$exclude_products = fn_my_changes_get_products_ids();
$params['exclude_pid'] = $exclude_products;
}
}
In function fn_my_changes_get_kare_products_ids()
getting product_ids that I want to exclude according to specific variant IDs:
function fn_my_changes_get_kare_products_ids() {
$kare_products_excluded = db_get_fields("SELECT product_id
FROM `?:product_features_values`
WHERE (`variant_id` = 137 OR `variant_id` = 394) AND lang_code = ?s", CART_LANGUAGE);
if($kare_products_excluded) {
return $kare_products_excluded;
}
}
I have already checked that exclude_pid
gets array… I have already tried to pass integers in array but still getting all the products…
Last but not least, the products I want to exclude is about 15K… I do not know if this makes any troubles in mysql query (I guess not, but just saying)
Any help, please?