合并分支 'akun' 到 'master'
Akun 查看合并请求 !124
正在显示
1 个修改的文件
包含
43 行增加
和
13 行删除
| @@ -237,6 +237,7 @@ class ProjectUpdate extends Command | @@ -237,6 +237,7 @@ class ProjectUpdate extends Command | ||
| 237 | $items = $data_page['data']['data'] ?? []; | 237 | $items = $data_page['data']['data'] ?? []; |
| 238 | 238 | ||
| 239 | $model = new Product(); | 239 | $model = new Product(); |
| 240 | + $logic = new CategoryLogic(); | ||
| 240 | 241 | ||
| 241 | foreach ($items as $item) { | 242 | foreach ($items as $item) { |
| 242 | $route = $this->get_url_route($item['url'] ?? ''); | 243 | $route = $this->get_url_route($item['url'] ?? ''); |
| @@ -264,27 +265,32 @@ class ProjectUpdate extends Command | @@ -264,27 +265,32 @@ class ProjectUpdate extends Command | ||
| 264 | } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') { | 265 | } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') { |
| 265 | $type_arr[] = 3; | 266 | $type_arr[] = 3; |
| 266 | } else { | 267 | } else { |
| 267 | - $new_category[] = $cate; | 268 | + $new_category[] = $cate['id']; |
| 268 | } | 269 | } |
| 269 | } | 270 | } |
| 270 | if ($type_arr) { | 271 | if ($type_arr) { |
| 271 | $product_type = ',' . implode(',', $type_arr); | 272 | $product_type = ',' . implode(',', $type_arr); |
| 272 | } | 273 | } |
| 273 | 274 | ||
| 274 | - $category_arr = []; | ||
| 275 | - $pid = 0; | ||
| 276 | - for ($i = 0; $i < count($new_category); $i++) { | ||
| 277 | - $return = $this->get_category_name_arr($new_category, $pid); | ||
| 278 | - if ($return) { | ||
| 279 | - $category_arr[] = $this->special2str($return['name'] ?? ''); | ||
| 280 | - $pid = $return['id']; | ||
| 281 | - } | 275 | + if ($new_category) { |
| 276 | + $category_arr = $model->list(['original_id' => ['in', $new_category]]); | ||
| 277 | + $category_id = $logic->getLastCategory(array_column($category_arr, 'id')); | ||
| 282 | } | 278 | } |
| 283 | 279 | ||
| 284 | - if ($category_arr) { | ||
| 285 | - $categoryLogic = new CategoryLogic(); | ||
| 286 | - $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr)); | ||
| 287 | - } | 280 | +// $category_arr = []; |
| 281 | +// $pid = 0; | ||
| 282 | +// for ($i = 0; $i < count($new_category); $i++) { | ||
| 283 | +// $return = $this->get_category_name_arr($new_category, $pid); | ||
| 284 | +// if ($return) { | ||
| 285 | +// $category_arr[] = $this->special2str($return['name'] ?? ''); | ||
| 286 | +// $pid = $return['id']; | ||
| 287 | +// } | ||
| 288 | +// } | ||
| 289 | +// | ||
| 290 | +// if ($category_arr) { | ||
| 291 | +// $categoryLogic = new CategoryLogic(); | ||
| 292 | +// $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr)); | ||
| 293 | +// } | ||
| 288 | } | 294 | } |
| 289 | try { | 295 | try { |
| 290 | $item['ttile'] = $this->special2str($item['ttile'] ?? ''); | 296 | $item['ttile'] = $this->special2str($item['ttile'] ?? ''); |
| @@ -316,6 +322,30 @@ class ProjectUpdate extends Command | @@ -316,6 +322,30 @@ class ProjectUpdate extends Command | ||
| 316 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; | 322 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; |
| 317 | continue; | 323 | continue; |
| 318 | } | 324 | } |
| 325 | + } else { | ||
| 326 | + //分类 | ||
| 327 | + $category_id = ''; | ||
| 328 | + | ||
| 329 | + if ($item['category'] ?? []) { | ||
| 330 | + $type_arr = []; | ||
| 331 | + $new_category = []; | ||
| 332 | + foreach ($item['category'] as $cate) { | ||
| 333 | + if ($cate['parent'] == 0 && $cate['name'] == 'Featured Products') { | ||
| 334 | + $type_arr[] = 2; | ||
| 335 | + } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') { | ||
| 336 | + $type_arr[] = 3; | ||
| 337 | + } else { | ||
| 338 | + $new_category[] = $cate['id']; | ||
| 339 | + } | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + if ($new_category) { | ||
| 343 | + $category_arr = $model->list(['original_id' => ['in', $new_category]]); | ||
| 344 | + $category_id = $logic->getLastCategory(array_column($category_arr, 'id')); | ||
| 345 | + } | ||
| 346 | + } | ||
| 347 | + | ||
| 348 | + $model->edit(['category_id' => $category_id], ['id' => $product['id']]); | ||
| 319 | } | 349 | } |
| 320 | } | 350 | } |
| 321 | } | 351 | } |
-
请 注册 或 登录 后发表评论