作者 lyh

gx

... ... @@ -40,7 +40,7 @@ class CategoryController extends BaseController
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'].'/';
// $v['product_num'] = Category::getProductNum($v['id']);
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
$list[$k] = $v;
... ...
... ... @@ -53,15 +53,15 @@ class Category extends Base
public static function getProductNum($cate_id){
$cate_ids = self::getChildIdsArr($cate_id);
$str = 0;
foreach ($cate_ids as $v){
$info = self::where('pid',$v)->first();
if($info){
continue;
}else{
$count = Product::where('category_id','like','%,'.$v.',%')->count();
$str = $str+$count;
}
}
// foreach ($cate_ids as $v){
// $info = self::where('pid',$v)->first();
// if($info){
// continue;
// }else{
// $count = Product::where('category_id','like','%,'.$v.',%')->count();
// $str = $str+$count;
// }
// }
return $str;
}
}
... ...