正在显示
1 个修改的文件
包含
2 行增加
和
5 行删除
| @@ -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 | } |
-
请 注册 或 登录 后发表评论