商品搜索添加商品分类搜索

This commit is contained in:
wangxiaowei 2024-12-16 16:10:05 +08:00
parent edaad48c93
commit f8d0e6d576

@ -413,6 +413,7 @@ class GoodsLogic extends Logic
$where[] = ['shop_id', 'not in', self::filterShopsIds()];
}
// 平台分类
$get['platform_cate_id'] = 319;
if(isset($get['platform_cate_id']) && !empty($get['platform_cate_id']) && filter_var($get['platform_cate_id'], FILTER_VALIDATE_INT)) {
$category_msg = GoodsCategory::where("id",$get['platform_cate_id'])->find();
if($category_msg['pid'] == 0){
@ -425,7 +426,20 @@ class GoodsLogic extends Logic
$wh = "find_in_set(".$get['platform_cate_id'].", third_cate_id)";
}
}
}
$whereIn = '';
if (isset($get['cate']) && $get['cate']) {
$cate = GoodsCategory::where(['is_show' => 1, 'del' => 0])
->where([['name', 'like', '%' . trim($get['keyword']) . '%']])
->field('id')
->select()
->toArray();
$whereIn = array_map(function ($innerArray) {
return implode(',', $innerArray);
}, $cate);
$get['keyword'] = '';
}
// 品牌
@ -522,6 +536,7 @@ class GoodsLogic extends Logic
->field($field)
->where($wh)
->where($where)
->whereIn('first_cate_id|second_cate_id|third_cate_id', $whereIn)
->order($order)
->page($get['page_no'], $get['page_size'])
->select();