提交 c6910722 编写于 作者: D devil_gong

关键字搜索情况下筛选品牌

上级 dcd975f2
......@@ -71,7 +71,7 @@ class Search extends Common
return redirect(MyUrl('index/search/index', $p));
} else {
// 品牌列表
$this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->params['category_id']]));
$this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->params['category_id'], 'keywords'=>$this->params['keywords']]));
// 商品分类
$this->assign('category_list', SearchService::GoodsCategoryList(['category_id'=>$this->params['category_id']]));
......
......@@ -63,7 +63,7 @@ class AdminService
$where = [];
if(!empty($params['username']))
{
$where[] =['username', 'like', '%'.$params['username'].'%'];
$where[] = ['username', 'like', '%'.$params['username'].'%'];
}
if(isset($params['role_id']) && $params['role_id'] > -1)
{
......
......@@ -172,6 +172,8 @@ class BrandService
public static function CategoryBrandList($params = [])
{
$brand_where = ['is_enable'=>1];
// 分类id
if(!empty($params['category_id']))
{
// 根据分类获取品牌id
......@@ -181,6 +183,15 @@ class BrandService
$brand_where['id'] = Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->field('g.brand_id')->where($where)->group('g.brand_id')->column('brand_id');
}
// 关键字
if(!empty($params['keywords']))
{
$where = [
['title', 'like', '%'.$params['keywords'].'%']
];
$brand_where['id'] = Db::name('Goods')->where($where)->group('brand_id')->column('brand_id');
}
// 获取品牌列表
$brand = Db::name('Brand')->where($brand_where)->field('id,name,logo,website_url')->select();
if(!empty($brand))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册