正在显示
1 个修改的文件
包含
17 行增加
和
15 行删除
| @@ -256,11 +256,25 @@ class ProjectUpdate extends Command | @@ -256,11 +256,25 @@ class ProjectUpdate extends Command | ||
| 256 | $product_type = ''; | 256 | $product_type = ''; |
| 257 | 257 | ||
| 258 | if ($item['category'] ?? []) { | 258 | if ($item['category'] ?? []) { |
| 259 | - $category_arr = []; | 259 | + $type_arr = []; |
| 260 | + $new_category = []; | ||
| 261 | + foreach ($item['category'] as $cate) { | ||
| 262 | + if ($cate['parent'] == 0 && $cate['name'] == 'Featured Products') { | ||
| 263 | + $type_arr[] = 2; | ||
| 264 | + } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') { | ||
| 265 | + $type_arr[] = 3; | ||
| 266 | + }else{ | ||
| 267 | + $new_category[] = $cate; | ||
| 268 | + } | ||
| 269 | + } | ||
| 270 | + if ($type_arr) { | ||
| 271 | + $product_type = ',' . implode(',', $type_arr); | ||
| 272 | + } | ||
| 260 | 273 | ||
| 274 | + $category_arr = []; | ||
| 261 | $pid = 0; | 275 | $pid = 0; |
| 262 | - for ($i = 0; $i < count($item['category']); $i++) { | ||
| 263 | - $return = $this->get_category_name_arr($item['category'], $pid); | 276 | + for ($i = 0; $i < count($new_category); $i++) { |
| 277 | + $return = $this->get_category_name_arr($new_category, $pid); | ||
| 264 | if ($return) { | 278 | if ($return) { |
| 265 | $category_arr[] = $this->special2str($return['name'] ?? ''); | 279 | $category_arr[] = $this->special2str($return['name'] ?? ''); |
| 266 | $pid = $return['id']; | 280 | $pid = $return['id']; |
| @@ -271,18 +285,6 @@ class ProjectUpdate extends Command | @@ -271,18 +285,6 @@ class ProjectUpdate extends Command | ||
| 271 | $categoryLogic = new CategoryLogic(); | 285 | $categoryLogic = new CategoryLogic(); |
| 272 | $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr)); | 286 | $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr)); |
| 273 | } | 287 | } |
| 274 | - | ||
| 275 | - $type_arr = []; | ||
| 276 | - foreach ($item['category'] as $cate) { | ||
| 277 | - if ($cate['parent'] == 0 && $cate['name'] == 'Featured Products') { | ||
| 278 | - $type_arr[] = 2; | ||
| 279 | - } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') { | ||
| 280 | - $type_arr[] = 3; | ||
| 281 | - } | ||
| 282 | - } | ||
| 283 | - if ($type_arr) { | ||
| 284 | - $product_type = ',' . implode(',', $type_arr); | ||
| 285 | - } | ||
| 286 | } | 288 | } |
| 287 | try { | 289 | try { |
| 288 | $item['ttile'] = $this->special2str($item['ttile'] ?? ''); | 290 | $item['ttile'] = $this->special2str($item['ttile'] ?? ''); |
-
请 注册 或 登录 后发表评论