是否可以从搜索结果中排除特定类别的产品?无法通过fn.search.php
或tpl
文件找到任何方法。
答案 0 :(得分:0)
你可以使用钩子“get_products” 请添加到文件:
<?php
if (!defined('BOOTSTRAP')) { die('Access denied'); }
fn_register_hooks(
'get_products'
);
<?php
if (!defined('BOOTSTRAP')) { die('Access denied'); }
function fn_my_changes_get_products($params, $fields, $sortings, &$condition, $join, $sorting, $group_by, $lang_code, $having){
if (AREA=='C' && !empty($params['search_performed']) && $params['search_performed']=='Y') {
$cids = array(...); //ex: 15, 16, 17
$subcats = true;
if ($subcats) {
$_ids = db_get_fields(
"SELECT a.category_id"."
FROM ?:categories as a"."
LEFT JOIN ?:categories as b"."
ON b.category_id IN (?n)"."
WHERE a.id_path LIKE CONCAT(b.id_path, '/%')",
$cids
);
$cids = fn_array_merge($cids, $_ids, false);
}
$condition .= db_quote(" AND ?:categories.category_id NOT IN (?n)", $cids);
}
}
您需要填写$ cids数组,其中包含您希望排除产品的类别ID以及子类别
$ cids = array(...);
请确保: