作者 lyh

gx

@@ -67,9 +67,10 @@ class Category extends Base @@ -67,9 +67,10 @@ class Category extends Base
67 * @date 2023/4/28 67 * @date 2023/4/28
68 */ 68 */
69 public function getProductNum($cate_id){ 69 public function getProductNum($cate_id){
70 - $str = []; 70 + $str[] = $cate_id;
71 $cate_ids = $this->getAllSub($cate_id,$str); 71 $cate_ids = $this->getAllSub($cate_id,$str);
72 - $count = CategoryRelated::whereIn('cate_id',$cate_ids)->count(); 72 + $productArr = CategoryRelated::whereIn('cate_id',$cate_ids)->pluck('product_id')->toArray();
  73 + $count = count($productArr);
73 return $count; 74 return $count;
74 } 75 }
75 } 76 }