|
@@ -237,6 +237,8 @@ class ProjectUpdate extends Command |
|
@@ -237,6 +237,8 @@ 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
|
+ $category_model = new Category();
|
|
|
|
241
|
+ $logic = new CategoryLogic();
|
|
240
|
|
242
|
|
|
241
|
foreach ($items as $item) {
|
243
|
foreach ($items as $item) {
|
|
242
|
$route = $this->get_url_route($item['url'] ?? '');
|
244
|
$route = $this->get_url_route($item['url'] ?? '');
|
|
@@ -256,33 +258,26 @@ class ProjectUpdate extends Command |
|
@@ -256,33 +258,26 @@ class ProjectUpdate extends Command |
|
256
|
$product_type = '';
|
258
|
$product_type = '';
|
|
257
|
|
259
|
|
|
258
|
if ($item['category'] ?? []) {
|
260
|
if ($item['category'] ?? []) {
|
|
259
|
- $category_arr = [];
|
|
|
|
260
|
-
|
|
|
|
261
|
- $pid = 0;
|
|
|
|
262
|
- for ($i = 0; $i < count($item['category']); $i++) {
|
|
|
|
263
|
- $return = $this->get_category_name_arr($item['category'], $pid);
|
|
|
|
264
|
- if ($return) {
|
|
|
|
265
|
- $category_arr[] = $this->special2str($return['name'] ?? '');
|
|
|
|
266
|
- $pid = $return['id'];
|
|
|
|
267
|
- }
|
|
|
|
268
|
- }
|
|
|
|
269
|
-
|
|
|
|
270
|
- if ($category_arr) {
|
|
|
|
271
|
- $categoryLogic = new CategoryLogic();
|
|
|
|
272
|
- $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr));
|
|
|
|
273
|
- }
|
|
|
|
274
|
-
|
|
|
|
275
|
$type_arr = [];
|
261
|
$type_arr = [];
|
|
|
|
262
|
+ $new_category = [];
|
|
276
|
foreach ($item['category'] as $cate) {
|
263
|
foreach ($item['category'] as $cate) {
|
|
277
|
if ($cate['parent'] == 0 && $cate['name'] == 'Featured Products') {
|
264
|
if ($cate['parent'] == 0 && $cate['name'] == 'Featured Products') {
|
|
278
|
$type_arr[] = 2;
|
265
|
$type_arr[] = 2;
|
|
279
|
} elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') {
|
266
|
} elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') {
|
|
280
|
$type_arr[] = 3;
|
267
|
$type_arr[] = 3;
|
|
|
|
268
|
+ } else {
|
|
|
|
269
|
+ $new_category[] = $cate['id'];
|
|
281
|
}
|
270
|
}
|
|
282
|
}
|
271
|
}
|
|
|
|
272
|
+
|
|
283
|
if ($type_arr) {
|
273
|
if ($type_arr) {
|
|
284
|
$product_type = ',' . implode(',', $type_arr);
|
274
|
$product_type = ',' . implode(',', $type_arr);
|
|
285
|
}
|
275
|
}
|
|
|
|
276
|
+
|
|
|
|
277
|
+ if ($new_category) {
|
|
|
|
278
|
+ $category_arr = $category_model->list(['original_id' => ['in', $new_category]]);
|
|
|
|
279
|
+ $category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
|
|
|
|
280
|
+ }
|
|
286
|
}
|
281
|
}
|
|
287
|
try {
|
282
|
try {
|
|
288
|
$item['ttile'] = $this->special2str($item['ttile'] ?? '');
|
283
|
$item['ttile'] = $this->special2str($item['ttile'] ?? '');
|
|
@@ -507,6 +502,7 @@ class ProjectUpdate extends Command |
|
@@ -507,6 +502,7 @@ class ProjectUpdate extends Command |
|
507
|
'pid' => $pid,
|
502
|
'pid' => $pid,
|
|
508
|
'keywords' => $item['keywords'] ?? '',
|
503
|
'keywords' => $item['keywords'] ?? '',
|
|
509
|
'describe' => $item['description'] ?? '',
|
504
|
'describe' => $item['description'] ?? '',
|
|
|
|
505
|
+ 'original_id' => $item['id'],
|
|
510
|
'route' => $route
|
506
|
'route' => $route
|
|
511
|
]);
|
507
|
]);
|
|
512
|
$this->set_map($route, RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
508
|
$this->set_map($route, RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
|
@@ -525,18 +521,6 @@ class ProjectUpdate extends Command |
|
@@ -525,18 +521,6 @@ class ProjectUpdate extends Command |
|
525
|
}
|
521
|
}
|
|
526
|
}
|
522
|
}
|
|
527
|
|
523
|
|
|
528
|
- //获取分类名称数组
|
|
|
|
529
|
- protected function get_category_name_arr($category, $pid = 0)
|
|
|
|
530
|
- {
|
|
|
|
531
|
- foreach ($category as $k => $v) {
|
|
|
|
532
|
- if ($v['parent'] == $pid) {
|
|
|
|
533
|
- return $v;
|
|
|
|
534
|
- }
|
|
|
|
535
|
- }
|
|
|
|
536
|
-
|
|
|
|
537
|
- return [];
|
|
|
|
538
|
- }
|
|
|
|
539
|
-
|
|
|
|
540
|
//特殊字符转换
|
524
|
//特殊字符转换
|
|
541
|
protected function special2str($str)
|
525
|
protected function special2str($str)
|
|
542
|
{
|
526
|
{
|