|
@@ -381,80 +381,80 @@ class ProductLogic extends BaseLogic |
|
@@ -381,80 +381,80 @@ class ProductLogic extends BaseLogic |
|
381
|
*/
|
381
|
*/
|
|
382
|
public function importProduct($project_id, $user_id, $data)
|
382
|
public function importProduct($project_id, $user_id, $data)
|
|
383
|
{
|
383
|
{
|
|
384
|
- $category_id = '';
|
|
|
|
385
|
- if ($data[2]) {
|
|
|
|
386
|
- //处理分类
|
|
|
|
387
|
- $categoryLogic = new CategoryLogic();
|
|
|
|
388
|
- $category_id = $categoryLogic->importProductCategory($project_id, $data[2]);
|
|
|
|
389
|
- }
|
384
|
+ $product = $this->model->read(['title' => $data[0]]);
|
|
|
|
385
|
+ if (!$product) {
|
|
390
|
|
386
|
|
|
391
|
- $keyword_id = '';
|
|
|
|
392
|
- if($data[3]){
|
|
|
|
393
|
- //处理关键词
|
|
|
|
394
|
- $keywordLogic = new KeywordLogic();
|
|
|
|
395
|
- $keyword_id = $keywordLogic->importProductKeyword($project_id, $data[3]);
|
|
|
|
396
|
- }
|
387
|
+ $category_id = '';
|
|
|
|
388
|
+ if ($data[2]) {
|
|
|
|
389
|
+ //处理分类
|
|
|
|
390
|
+ $categoryLogic = new CategoryLogic();
|
|
|
|
391
|
+ $category_id = $categoryLogic->importProductCategory($project_id, $data[2]);
|
|
|
|
392
|
+ }
|
|
397
|
|
393
|
|
|
398
|
- $gallery = [];
|
|
|
|
399
|
- $thumb = '';
|
|
|
|
400
|
- if($data[7]){
|
|
|
|
401
|
- //处理图片
|
|
|
|
402
|
- $img_arr = explode(',',$data[7]);
|
|
|
|
403
|
- foreach ($img_arr as $v_img){
|
|
|
|
404
|
- if($v_img){
|
|
|
|
405
|
- $one_img = CosService::uploadRemote($project_id,'image_product',$v_img);
|
|
|
|
406
|
- if($one_img){
|
|
|
|
407
|
- $one_gallery = [
|
|
|
|
408
|
- 'alt' => '这是一张产品图',
|
|
|
|
409
|
- 'url' => $one_img
|
|
|
|
410
|
- ];
|
394
|
+ $keyword_id = '';
|
|
|
|
395
|
+ if($data[3]){
|
|
|
|
396
|
+ //处理关键词
|
|
|
|
397
|
+ $keywordLogic = new KeywordLogic();
|
|
|
|
398
|
+ $keyword_id = $keywordLogic->importProductKeyword($project_id, $data[3]);
|
|
|
|
399
|
+ }
|
|
411
|
|
400
|
|
|
412
|
- if(!$thumb){
|
|
|
|
413
|
- $thumb = Arr::a2s($one_gallery);
|
|
|
|
414
|
- }
|
401
|
+ $gallery = [];
|
|
|
|
402
|
+ $thumb = '';
|
|
|
|
403
|
+ if($data[7]){
|
|
|
|
404
|
+ //处理图片
|
|
|
|
405
|
+ $img_arr = explode(',',$data[7]);
|
|
|
|
406
|
+ foreach ($img_arr as $v_img){
|
|
|
|
407
|
+ if($v_img){
|
|
|
|
408
|
+ $one_img = CosService::uploadRemote($project_id,'image_product',$v_img);
|
|
|
|
409
|
+ if($one_img){
|
|
|
|
410
|
+ $one_gallery = [
|
|
|
|
411
|
+ 'alt' => '这是一张产品图',
|
|
|
|
412
|
+ 'url' => $one_img
|
|
|
|
413
|
+ ];
|
|
|
|
414
|
+
|
|
|
|
415
|
+ if(!$thumb){
|
|
|
|
416
|
+ $thumb = Arr::a2s($one_gallery);
|
|
|
|
417
|
+ }
|
|
415
|
|
418
|
|
|
416
|
- $gallery[] = $one_gallery;
|
419
|
+ $gallery[] = $one_gallery;
|
|
|
|
420
|
+ }
|
|
417
|
}
|
421
|
}
|
|
418
|
}
|
422
|
}
|
|
419
|
}
|
423
|
}
|
|
420
|
- }
|
|
|
|
421
|
|
424
|
|
|
422
|
- $intro = '';
|
|
|
|
423
|
- if($data[5]){
|
|
|
|
424
|
- //处理短描述中的图片
|
|
|
|
425
|
- $pattern = '<img src="(.*?)">';
|
|
|
|
426
|
- preg_match_all($pattern, $data[5], $result_intro);
|
|
|
|
427
|
- if($result_intro[1]){
|
|
|
|
428
|
- foreach ($result_intro[1] as $vi_img){
|
|
|
|
429
|
- $data[5] = str_replace($vi_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_img)),$data[5]);
|
425
|
+ $intro = '';
|
|
|
|
426
|
+ if($data[5]){
|
|
|
|
427
|
+ //处理短描述中的图片
|
|
|
|
428
|
+ $pattern = '<img src="(.*?)">';
|
|
|
|
429
|
+ preg_match_all($pattern, $data[5], $result_intro);
|
|
|
|
430
|
+ if($result_intro[1]){
|
|
|
|
431
|
+ foreach ($result_intro[1] as $vi_img){
|
|
|
|
432
|
+ $data[5] = str_replace($vi_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_img)),$data[5]);
|
|
|
|
433
|
+ }
|
|
430
|
}
|
434
|
}
|
|
|
|
435
|
+ $intro = $data[5];
|
|
431
|
}
|
436
|
}
|
|
432
|
- $intro = $data[5];
|
|
|
|
433
|
- }
|
|
|
|
434
|
|
437
|
|
|
435
|
- $content = '';
|
|
|
|
436
|
- if($data[6]){
|
|
|
|
437
|
- //处理内容中的图片
|
|
|
|
438
|
- $pattern = '<img src="(.*?)">';
|
|
|
|
439
|
- preg_match_all($pattern, $data[6], $result_content);
|
|
|
|
440
|
- if($result_content[1]){
|
|
|
|
441
|
- foreach ($result_content[1] as $vc_img){
|
|
|
|
442
|
- $data[6] = str_replace($vc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_img)),$data[6]);
|
438
|
+ $content = '';
|
|
|
|
439
|
+ if($data[6]){
|
|
|
|
440
|
+ //处理内容中的图片
|
|
|
|
441
|
+ $pattern = '<img src="(.*?)">';
|
|
|
|
442
|
+ preg_match_all($pattern, $data[6], $result_content);
|
|
|
|
443
|
+ if($result_content[1]){
|
|
|
|
444
|
+ foreach ($result_content[1] as $vc_img){
|
|
|
|
445
|
+ $data[6] = str_replace($vc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_img)),$data[6]);
|
|
|
|
446
|
+ }
|
|
443
|
}
|
447
|
}
|
|
|
|
448
|
+ $content = $data[6];
|
|
444
|
}
|
449
|
}
|
|
445
|
- $content = $data[6];
|
|
|
|
446
|
- }
|
|
|
|
447
|
-
|
|
|
|
448
|
|
450
|
|
|
449
|
- //处理seo
|
|
|
|
450
|
- $seo_mate = [
|
|
|
|
451
|
- 'title' => $data[8]??'',
|
|
|
|
452
|
- 'keyword' => $data[9]??'',
|
|
|
|
453
|
- 'description' => $data[10]??''
|
|
|
|
454
|
- ];
|
451
|
+ //处理seo
|
|
|
|
452
|
+ $seo_mate = [
|
|
|
|
453
|
+ 'title' => $data[8]??'',
|
|
|
|
454
|
+ 'keyword' => $data[9]??'',
|
|
|
|
455
|
+ 'description' => $data[10]??''
|
|
|
|
456
|
+ ];
|
|
455
|
|
457
|
|
|
456
|
- $product = $this->model->read(['title' => $data[0]]);
|
|
|
|
457
|
- if (!$product) {
|
|
|
|
458
|
$id = $this->model->addReturnId(
|
458
|
$id = $this->model->addReturnId(
|
|
459
|
[
|
459
|
[
|
|
460
|
'project_id' => $project_id,
|
460
|
'project_id' => $project_id,
|