作者 赵彬吉

update

@@ -38,7 +38,7 @@ class CategoryController extends BaseController @@ -38,7 +38,7 @@ class CategoryController extends BaseController
38 if(!empty($list)){ 38 if(!empty($list)){
39 foreach ($list as $k =>$v){ 39 foreach ($list as $k =>$v){
40 $v['url'] = $this->user['domain'] . $v['route']; 40 $v['url'] = $this->user['domain'] . $v['route'];
41 - $v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->count();; 41 + $v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->count();
42 $v['image_link'] = getImageUrl($v['image']); 42 $v['image_link'] = getImageUrl($v['image']);
43 $list[$k] = $v; 43 $list[$k] = $v;
44 } 44 }
@@ -75,6 +75,10 @@ class CategoryController extends BaseController @@ -75,6 +75,10 @@ class CategoryController extends BaseController
75 $v = (array)$v; 75 $v = (array)$v;
76 if ($v['pid'] == 0) { 76 if ($v['pid'] == 0) {
77 $v['sub'] = _get_child($v['id'], $list); 77 $v['sub'] = _get_child($v['id'], $list);
  78 + foreach ($v['sub'] as $sub){
  79 + $v['product_num'] += $sub['product_num'];
  80 + }
  81 +
78 $data[] = $v; 82 $data[] = $v;
79 } 83 }
80 } 84 }
@@ -127,11 +127,11 @@ class CategoryLogic extends BaseLogic @@ -127,11 +127,11 @@ class CategoryLogic extends BaseLogic
127 if(($info['pid'] != $param['pid']) && ($sub_info != false)){ 127 if(($info['pid'] != $param['pid']) && ($sub_info != false)){
128 $this->fail('当前分类拥有子分类,不允许修改上级分类'); 128 $this->fail('当前分类拥有子分类,不允许修改上级分类');
129 } 129 }
130 - $productModel = new Product();  
131 - $product_info = $productModel->read(['category_id'=>['like','%'.$param['id'].'%']]);  
132 - if(($product_info !== false) && ($info['pid'] != $param['pid'])){  
133 - $this->fail('当前产品分类拥有产品不允许编辑上级分类');  
134 - } 130 +// $productModel = new Product();
  131 +// $product_info = $productModel->read(['category_id'=>['like','%'.$param['id'].'%']]);
  132 +// if(($product_info !== false) && ($info['pid'] != $param['pid'])){
  133 +// $this->fail('当前产品分类拥有产品不允许编辑上级分类');
  134 +// }
135 return $this->success(); 135 return $this->success();
136 } 136 }
137 137