gpt4 book ai didi

php - 从 CS 购物车的网站搜索中排除类别

转载 作者:行者123 更新时间:2023-11-29 19:26:21 24 4
gpt4 key购买 nike

是否可以从搜索结果中排除特定类别的产品?无法通过 fn.search.phptpl 文件找到任何方法。

最佳答案

您可以使用钩子(Hook)“get_products”请添加到文件:

app/addons/my_changes/init.php

<?php

if (!defined('BOOTSTRAP')) { die('Access denied'); }

fn_register_hooks(
'get_products'
);

app/addons/my_changes/func.php

<?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);
}
}

您需要使用您希望排除产品的类别 ID 以及子类别来填充 $cids 数组

$cids = array(...);

请确保:

  • “我的更改”插件已激活
  • 如果文件丢失,您需要创建

关于php - 从 CS 购物车的网站搜索中排除类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42112391/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com