1]; if(!empty($params['category_id'])) { // 根据分类获取品牌id $category_ids = GoodsService::GoodsCategoryItemsIds(['category_id'=>$params['category_id']]); $where = ['g.is_delete_time'=>0, 'g.is_shelves'=>1, 'gci.id'=>['in', $category_ids]]; $brand_ids = M('Goods')->alias('g')->join(' INNER JOIN __GOODS_CATEGORY_JOIN__ AS gci ON g.id=gci.goods_id')->field('g.brand_id')->where($where)->group('g.brand_id')->getField('brand_id', true); $brand_where['id'] = ['in', $brand_ids]; } // 获取品牌列表 $brand = M('Brand')->where($brand_where)->field('id,name,logo,website_url')->select(); if(!empty($brand)) { $images_host = C('IMAGE_HOST'); foreach($brand as &$v) { $v['logo_old'] = $v['logo']; $v['logo'] = empty($v['logo']) ? null : $images_host.$v['logo']; $v['website_url'] = empty($v['website_url']) ? null : $v['website_url']; } } return $brand; } } ?>