作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !120
@@ -263,7 +263,7 @@ class ProjectUpdate extends Command @@ -263,7 +263,7 @@ class ProjectUpdate extends Command
263 $type_arr[] = 2; 263 $type_arr[] = 2;
264 } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') { 264 } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') {
265 $type_arr[] = 3; 265 $type_arr[] = 3;
266 - }else{ 266 + } else {
267 $new_category[] = $cate; 267 $new_category[] = $cate;
268 } 268 }
269 } 269 }
@@ -316,6 +316,45 @@ class ProjectUpdate extends Command @@ -316,6 +316,45 @@ class ProjectUpdate extends Command
316 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 316 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
317 continue; 317 continue;
318 } 318 }
  319 + } else {
  320 + //分类
  321 + $category_id = '';
  322 + //产品类型,2Featured Products,3Hot Products
  323 + $product_type = '';
  324 +
  325 + if ($item['category'] ?? []) {
  326 + $type_arr = [];
  327 + $new_category = [];
  328 + foreach ($item['category'] as $cate) {
  329 + if ($cate['parent'] == 0 && $cate['name'] == 'Featured Products') {
  330 + $type_arr[] = 2;
  331 + } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') {
  332 + $type_arr[] = 3;
  333 + } else {
  334 + $new_category[] = $cate;
  335 + }
  336 + }
  337 + if ($type_arr) {
  338 + $product_type = ',' . implode(',', $type_arr);
  339 + }
  340 +
  341 + $category_arr = [];
  342 + $pid = 0;
  343 + for ($i = 0; $i < count($new_category); $i++) {
  344 + $return = $this->get_category_name_arr($new_category, $pid);
  345 + if ($return) {
  346 + $category_arr[] = $this->special2str($return['name'] ?? '');
  347 + $pid = $return['id'];
  348 + }
  349 + }
  350 +
  351 + if ($category_arr) {
  352 + $categoryLogic = new CategoryLogic();
  353 + $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr));
  354 + }
  355 + }
  356 +
  357 + $model->edit(['category_id' => $category_id, 'product_type' => $product_type], ['id' => $product['id']]);
319 } 358 }
320 } 359 }
321 } 360 }