浏览代码

平台花材更新

shish 5 年之前
父节点
当前提交
18ab293d05
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      console/controllers/ProductController.php

+ 19 - 0
console/controllers/ProductController.php

@@ -47,4 +47,23 @@ class ProductController extends Controller
         }
     }
 
+    //更新重量 ./yii product/update-weight
+    public function actionUpdateWeight()
+    {
+        $list = ProductClass::getAllByCondition(['shopId' => 10], null, '*', null, true);
+        if (empty($list)) {
+            return false;
+        }
+        foreach ($list as $product) {
+            $itemId = $product->itemId ?? 0;
+            $ptItem = PtItemClass::getById($itemId, true);
+            $weight = $product->weight ?? 0;
+            if (!empty($weight)) {
+                $ptItem->weight = $weight;
+                $ptItem->save();
+                echo "平台花材{$ptItem->id} 重量已更新为{$weight} \n";
+            }
+        }
+    }
+
 }