在CS购物车

时间:2017-02-08 11:53:32

标签: php mysql smarty cs-cart

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

1 个答案:

答案 0 :(得分:0)

你可以使用钩子“get_products” 请添加到文件:

的应用程序/插件/ my_changes /的init.php

<?php

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

fn_register_hooks(
    'get_products'
);

的应用程序/插件/ 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);
    }
}

您需要填写$ cids数组,其中包含您希望排除产品的类别ID以及子类别

  

$ cids = array(...);

请确保:

  • 我的更改加载项已激活
  • 如果缺少文件,则需要创建