|
...
|
...
|
@@ -169,7 +169,26 @@ class ProductController extends BaseController |
|
|
|
}
|
|
|
|
$this->param['featured_status'] = $this->param['featured_status'] ?? 0;
|
|
|
|
if($this->param['featured_status'] != Category::STATUS_ACTIVE) {
|
|
|
|
$query = $query->where('title','not like','Featured%');
|
|
|
|
$cateModel = new Category();
|
|
|
|
$featured_ids = $cateModel->where('title', 'like', 'Featured%')->pluck('id')->toArray();
|
|
|
|
if(!empty($featured_ids)){
|
|
|
|
$status = [];
|
|
|
|
if(isset($this->map['status'])){
|
|
|
|
$status = ['status'=>$this->map['status']];
|
|
|
|
}
|
|
|
|
$cateList = $cateModel->list($status,'id',['id','pid']);
|
|
|
|
//获取当前的子集
|
|
|
|
$featured_arr = [];
|
|
|
|
foreach ($featured_ids as $id){
|
|
|
|
$featured_arr = array_merge($featured_arr,array_unique(_get_all_sub($id,$cateList)));
|
|
|
|
}
|
|
|
|
if(!empty($featured_arr)){
|
|
|
|
$cateRelated = new CategoryRelated();
|
|
|
|
$product_ids = $cateRelated->whereIn('cate_id',$featured_arr)->pluck('product_id')->unique()->toArray();
|
|
|
|
$query = $query->whereNotIn('id',$product_ids);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return $query;
|
|
|
|
}
|
...
|
...
|
|