作者 刘锟

update

@@ -238,6 +238,7 @@ class ProjectUpdate extends Command @@ -238,6 +238,7 @@ class ProjectUpdate extends Command
238 238
239 $model = new Product(); 239 $model = new Product();
240 240
  241 + $category_model = new Category();
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'] ?? '');
243 if ($route) { 244 if ($route) {
@@ -252,6 +253,9 @@ class ProjectUpdate extends Command @@ -252,6 +253,9 @@ class ProjectUpdate extends Command
252 } 253 }
253 //分类 254 //分类
254 $category_id = ''; 255 $category_id = '';
  256 + //产品类型,2Featured Products,3Hot Products
  257 + $product_type = '';
  258 +
255 if ($item['category'] ?? []) { 259 if ($item['category'] ?? []) {
256 $category_arr = []; 260 $category_arr = [];
257 261
@@ -268,6 +272,18 @@ class ProjectUpdate extends Command @@ -268,6 +272,18 @@ class ProjectUpdate extends Command
268 $categoryLogic = new CategoryLogic(); 272 $categoryLogic = new CategoryLogic();
269 $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr)); 273 $category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr));
270 } 274 }
  275 +
  276 + $type_arr = [];
  277 + foreach ($item['category'] as $cate) {
  278 + if ($cate['parent'] == 0 && $cate['name'] == 'Featured Products') {
  279 + $type_arr[] = 2;
  280 + } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') {
  281 + $type_arr[] = 3;
  282 + }
  283 + }
  284 + if ($type_arr) {
  285 + $product_type = ',' . implode(',', $type_arr);
  286 + }
271 } 287 }
272 try { 288 try {
273 $item['ttile'] = $this->special2str($item['ttile'] ?? ''); 289 $item['ttile'] = $this->special2str($item['ttile'] ?? '');
@@ -279,6 +295,7 @@ class ProjectUpdate extends Command @@ -279,6 +295,7 @@ class ProjectUpdate extends Command
279 'category_id' => $category_id, 295 'category_id' => $category_id,
280 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', 296 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
281 'gallery' => Arr::a2s($gallery), 297 'gallery' => Arr::a2s($gallery),
  298 + 'product_type' => $product_type,
282 'seo_mate' => Arr::a2s([ 299 'seo_mate' => Arr::a2s([
283 'title' => $item['ttile'], 300 'title' => $item['ttile'],
284 'keyword' => $item['keywords'] ?? '', 301 'keyword' => $item['keywords'] ?? '',