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

This commit is contained in:
devil_gong 2019-01-22 13:38:23 +08:00
parent dcd975f271
commit c691072200
3 changed files with 13 additions and 2 deletions

View File

@ -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']]));

View File

@ -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)
{

View File

@ -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))