shish пре 2 година
родитељ
комит
a7b2a6db4e
1 измењених фајлова са 14 додато и 8 уклоњено
  1. 14 8
      console/controllers/ProductController.php

+ 14 - 8
console/controllers/ProductController.php

@@ -153,22 +153,28 @@ class ProductController extends Controller
     }
 
     //二个空间问题
-    public function actionEmpty()
+    public function actionSame()
     {
+        ini_set('memory_limit', '5045M');
+        set_time_limit(0);
         if (getenv('YII_ENV') == 'production') {
             $mainId = 8164;
         } else {
             $mainId = 644;
         }
-        $list = ProductClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
+        $list = ProductClass::getAllByCondition(['mainId' => $mainId], null, '*', null);
         if (!empty($list)) {
+            $ids = array_column($list, 'itemId');
+            $ptInfo = PtItemClass::getByIds($ids, null, 'id');
             foreach ($list as $item) {
-                $name = $item->name ?? '';
-                $name = trim($name);
-                $name = str_replace("   ", " ", $name);
-                $name = str_replace("  ", " ", $name);
-                $item->name = $name;
-                $item->save();
+                $id = $item['id'] ?? 0;
+                $name = $item['name'] ?? '';
+                $ptItemId = $item['itemId'] ?? 0;
+                $pt = $ptInfo[$ptItemId];
+                $ptName = $pt['name'] ?? '';
+                if ($name != $ptName) {
+                    echo $id . ' ' . $name . ' ' . $ptName . "\n";
+                }
             }
         }
     }