|
...
|
...
|
@@ -237,6 +237,7 @@ class ProjectUpdate extends Command |
|
|
|
$items = $data_page['data']['data'] ?? [];
|
|
|
|
|
|
|
|
$model = new Product();
|
|
|
|
$logic = new CategoryLogic();
|
|
|
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
$route = $this->get_url_route($item['url'] ?? '');
|
|
...
|
...
|
@@ -264,27 +265,32 @@ class ProjectUpdate extends Command |
|
|
|
} elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') {
|
|
|
|
$type_arr[] = 3;
|
|
|
|
} else {
|
|
|
|
$new_category[] = $cate;
|
|
|
|
$new_category[] = $cate['id'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($type_arr) {
|
|
|
|
$product_type = ',' . implode(',', $type_arr);
|
|
|
|
}
|
|
|
|
|
|
|
|
$category_arr = [];
|
|
|
|
$pid = 0;
|
|
|
|
for ($i = 0; $i < count($new_category); $i++) {
|
|
|
|
$return = $this->get_category_name_arr($new_category, $pid);
|
|
|
|
if ($return) {
|
|
|
|
$category_arr[] = $this->special2str($return['name'] ?? '');
|
|
|
|
$pid = $return['id'];
|
|
|
|
}
|
|
|
|
if ($new_category) {
|
|
|
|
$category_arr = $model->list(['original_id' => ['in', $new_category]]);
|
|
|
|
$category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($category_arr) {
|
|
|
|
$categoryLogic = new CategoryLogic();
|
|
|
|
$category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr));
|
|
|
|
}
|
|
|
|
// $category_arr = [];
|
|
|
|
// $pid = 0;
|
|
|
|
// for ($i = 0; $i < count($new_category); $i++) {
|
|
|
|
// $return = $this->get_category_name_arr($new_category, $pid);
|
|
|
|
// if ($return) {
|
|
|
|
// $category_arr[] = $this->special2str($return['name'] ?? '');
|
|
|
|
// $pid = $return['id'];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if ($category_arr) {
|
|
|
|
// $categoryLogic = new CategoryLogic();
|
|
|
|
// $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr));
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$item['ttile'] = $this->special2str($item['ttile'] ?? '');
|
|
...
|
...
|
@@ -316,6 +322,30 @@ class ProjectUpdate extends Command |
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//分类
|
|
|
|
$category_id = '';
|
|
|
|
|
|
|
|
if ($item['category'] ?? []) {
|
|
|
|
$type_arr = [];
|
|
|
|
$new_category = [];
|
|
|
|
foreach ($item['category'] as $cate) {
|
|
|
|
if ($cate['parent'] == 0 && $cate['name'] == 'Featured Products') {
|
|
|
|
$type_arr[] = 2;
|
|
|
|
} elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') {
|
|
|
|
$type_arr[] = 3;
|
|
|
|
} else {
|
|
|
|
$new_category[] = $cate['id'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($new_category) {
|
|
|
|
$category_arr = $model->list(['original_id' => ['in', $new_category]]);
|
|
|
|
$category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$model->edit(['category_id' => $category_id], ['id' => $product['id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
...
|
...
|
|