Browse Source

商品分类修改,规格微调

lizhen_gitee 10 months ago
parent
commit
0b4591e6b7
2 changed files with 10 additions and 3 deletions
  1. 5 3
      addons/unishop/controller/Product.php
  2. 5 0
      addons/unishop/model/Product.php

+ 5 - 3
addons/unishop/controller/Product.php

@@ -139,14 +139,14 @@ class Product extends Base
         $by = input('by', 'weigh');
         $desc = input('desc', 'desc');
 
-        $sid = input('sid'); // 二级分类Id
+//        $sid = input('sid'); // 二级分类Id
         $fid = input('fid'); // 一级分类Id
 
         $keyword = input('keyword','');//搜索
 
         $productModel = new productModel();
 
-        if ($fid && !$sid) {
+       /* if ($fid && !$sid) {
             $categoryModel = new \addons\unishop\model\Category();
             $sArr = $categoryModel->where('pid', $fid)->field('id')->select();
             $sArr = array_column($sArr, 'id');
@@ -154,7 +154,9 @@ class Product extends Base
             $productModel->where('category_id', 'in', $sArr);
         } else {
             $sid && $productModel->where(['category_id' => $sid]);
-        }
+        }*/
+
+        $fid && $productModel->where(['category_id' => $fid]);
 
         if(!empty($keyword)){
             $productModel->where('title', 'LIKE', '%'.$keyword.'%');

+ 5 - 0
addons/unishop/model/Product.php

@@ -123,6 +123,11 @@ class Product extends Model
         $specs = !empty($data['specTableList']) ? json_decode($data['specTableList'], true) : [];
         foreach ($specs as &$spec) {
             $spec['image'] = Config::getImagesFullUrl($spec['image']);
+
+            $spec['value_text'] = '';
+            if(!empty($spec['value'])){
+                $spec['value_text'] = implode(',',$spec['value']);
+            }
         }
         return $specs;
     }