作者 lyh

gx

@@ -52,11 +52,8 @@ class Category extends Base @@ -52,11 +52,8 @@ class Category extends Base
52 */ 52 */
53 public static function getProductNum($cate_id){ 53 public static function getProductNum($cate_id){
54 $cate_ids = self::getChildIdsArr($cate_id); 54 $cate_ids = self::getChildIdsArr($cate_id);
55 - $str = 0;  
56 - foreach ($cate_ids as $v){  
57 - $count = Product::where('category_id','like','%,'.$v.',%')->count();  
58 - $str = $str+$count;  
59 - } 55 + $count = CategoryRelated::whereIn('category_id',$cate_ids)->count();
  56 + $str = $count;
60 return $str; 57 return $str;
61 } 58 }
62 } 59 }