|
...
|
...
|
@@ -237,6 +237,8 @@ class ProjectUpdate extends Command |
|
|
|
$items = $data_page['data']['data'] ?? [];
|
|
|
|
|
|
|
|
$model = new Product();
|
|
|
|
$category_model = new Category();
|
|
|
|
$logic = new CategoryLogic();
|
|
|
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
$route = $this->get_url_route($item['url'] ?? '');
|
|
...
|
...
|
@@ -256,33 +258,26 @@ class ProjectUpdate extends Command |
|
|
|
$product_type = '';
|
|
|
|
|
|
|
|
if ($item['category'] ?? []) {
|
|
|
|
$category_arr = [];
|
|
|
|
|
|
|
|
$pid = 0;
|
|
|
|
for ($i = 0; $i < count($item['category']); $i++) {
|
|
|
|
$return = $this->get_category_name_arr($item['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));
|
|
|
|
}
|
|
|
|
|
|
|
|
$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 ($type_arr) {
|
|
|
|
$product_type = ',' . implode(',', $type_arr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($new_category) {
|
|
|
|
$category_arr = $category_model->list(['original_id' => ['in', $new_category]]);
|
|
|
|
$category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$item['ttile'] = $this->special2str($item['ttile'] ?? '');
|
|
...
|
...
|
@@ -507,6 +502,7 @@ class ProjectUpdate extends Command |
|
|
|
'pid' => $pid,
|
|
|
|
'keywords' => $item['keywords'] ?? '',
|
|
|
|
'describe' => $item['description'] ?? '',
|
|
|
|
'original_id' => $item['id'],
|
|
|
|
'route' => $route
|
|
|
|
]);
|
|
|
|
$this->set_map($route, RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
|
...
|
...
|
@@ -525,18 +521,6 @@ class ProjectUpdate extends Command |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取分类名称数组
|
|
|
|
protected function get_category_name_arr($category, $pid = 0)
|
|
|
|
{
|
|
|
|
foreach ($category as $k => $v) {
|
|
|
|
if ($v['parent'] == $pid) {
|
|
|
|
return $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
//特殊字符转换
|
|
|
|
protected function special2str($str)
|
|
|
|
{
|
...
|
...
|
|