正在显示
1 个修改的文件
包含
27 行增加
和
1 行删除
| @@ -14,6 +14,7 @@ use App\Models\CustomModule\CustomModuleContent; | @@ -14,6 +14,7 @@ use App\Models\CustomModule\CustomModuleContent; | ||
| 14 | use App\Models\CustomModule\CustomModuleExtentContent; | 14 | use App\Models\CustomModule\CustomModuleExtentContent; |
| 15 | use App\Models\News\News; | 15 | use App\Models\News\News; |
| 16 | use App\Models\Product\Category; | 16 | use App\Models\Product\Category; |
| 17 | +use App\Models\Product\Product; | ||
| 17 | use App\Models\RouteMap\RouteMap; | 18 | use App\Models\RouteMap\RouteMap; |
| 18 | use App\Models\Template\BTemplate; | 19 | use App\Models\Template\BTemplate; |
| 19 | use App\Models\Template\Template; | 20 | use App\Models\Template\Template; |
| @@ -78,7 +79,32 @@ class LyhImportTest extends Command | @@ -78,7 +79,32 @@ class LyhImportTest extends Command | ||
| 78 | $line_of_text[] = fgetcsv($file_handle, 0, ','); | 79 | $line_of_text[] = fgetcsv($file_handle, 0, ','); |
| 79 | } | 80 | } |
| 80 | fclose($file_handle); | 81 | fclose($file_handle); |
| 81 | - dd($line_of_text); | 82 | + $cateModel = new Category(); |
| 83 | + $productModel = new Product(); | ||
| 84 | + foreach ($line_of_text as $k => $val){ | ||
| 85 | + dd($val); | ||
| 86 | + if($k < 2){ | ||
| 87 | + continue; | ||
| 88 | + } | ||
| 89 | + $saveData = []; | ||
| 90 | + if($val[1] ?? ''){ | ||
| 91 | + $saveData['title'] = $val[1]; | ||
| 92 | + }else{ | ||
| 93 | + continue; | ||
| 94 | + } | ||
| 95 | + if($val[0] ?? ''){ | ||
| 96 | + $cateInfo = $cateModel->read(['seo_title'=>trim($val[0])]); | ||
| 97 | + if($cateInfo !== false){ | ||
| 98 | + $saveData['category_id'] = $cateInfo['id']; | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + if($val[2] ?? ''){ | ||
| 102 | + $cateInfo = $cateModel->read(['seo_title'=>trim($val[0])]); | ||
| 103 | + if($cateInfo !== false){ | ||
| 104 | + $saveData['category_id'] = $cateInfo['id']; | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + } | ||
| 82 | } | 108 | } |
| 83 | 109 | ||
| 84 | public function handleCatePid(){ | 110 | public function handleCatePid(){ |
-
请 注册 或 登录 后发表评论