|
@@ -9,6 +9,7 @@ use Illuminate\Support\Str;
|
|
|
|
|
|
/**
|
|
|
* 导入相册内容到产品表
|
|
|
+ * 先在log中复制$tableMapping到这里,然后运行命令
|
|
|
* php artisan sync:album-content
|
|
|
*/
|
|
|
class SyncAlbumContent extends Command
|
|
@@ -34,7 +35,8 @@ class SyncAlbumContent extends Command
|
|
|
*/
|
|
|
public function handle()
|
|
|
{
|
|
|
- $tableMapping = json_decode('[{"base_product_category":11,"album_path_id":21},{"base_product_category":12,"album_path_id":22},{"base_product_category":13,"album_path_id":31},{"base_product_category":14,"album_path_id":35},{"base_product_category":15,"album_path_id":51},{"base_product_category":16,"album_path_id":64},{"base_product_category":17,"album_path_id":74},{"base_product_category":18,"album_path_id":79},{"base_product_category":19,"album_path_id":83},{"base_product_category":20,"album_path_id":114},{"base_product_category":21,"album_path_id":123},{"base_product_category":22,"album_path_id":141},{"base_product_category":23,"album_path_id":142},{"base_product_category":24,"album_path_id":143},{"base_product_category":25,"album_path_id":145},{"base_product_category":26,"album_path_id":151},{"base_product_category":27,"album_path_id":153},{"base_product_category":28,"album_path_id":154}] ');
|
|
|
+ exit;
|
|
|
+ $tableMapping = json_decode(' [{"base_product_category":11,"album_path_id":21},{"base_product_category":12,"album_path_id":22},{"base_product_category":13,"album_path_id":31},{"base_product_category":14,"album_path_id":35},{"base_product_category":15,"album_path_id":51},{"base_product_category":16,"album_path_id":64},{"base_product_category":17,"album_path_id":74},{"base_product_category":18,"album_path_id":79},{"base_product_category":19,"album_path_id":83},{"base_product_category":20,"album_path_id":114},{"base_product_category":21,"album_path_id":123},{"base_product_category":22,"album_path_id":141},{"base_product_category":23,"album_path_id":142},{"base_product_category":24,"album_path_id":143},{"base_product_category":25,"album_path_id":145},{"base_product_category":26,"album_path_id":151},{"base_product_category":27,"album_path_id":153},{"base_product_category":28,"album_path_id":154}] ');
|
|
|
|
|
|
foreach ($tableMapping as $mapping) {
|
|
|
$mapping = (array)$mapping;
|
|
@@ -54,21 +56,26 @@ class SyncAlbumContent extends Command
|
|
|
$content = "";
|
|
|
if ($detail) {
|
|
|
foreach ($detail as $key => $value) {
|
|
|
- $content .= '<img src="'. $value. '"">';
|
|
|
+ $content .= '<img src="'. $value. '" width="100%">';
|
|
|
}
|
|
|
}
|
|
|
if ($detail_cn) {
|
|
|
foreach ($detail_cn as $key => $value) {
|
|
|
- $content .= '<img src="'. $value. '"">';
|
|
|
+ $content .= '<img src="'. $value. '" width="100%">';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$baseProductId = 0;
|
|
|
+ $sku = '';
|
|
|
+ if (strpos($albumContent->model, "MTB-") === 0) {
|
|
|
+ $sku = $albumContent->model;
|
|
|
+ }
|
|
|
if (!$baseProduct) {
|
|
|
$baseProduct = DB::table('base_product')
|
|
|
->insertGetId([
|
|
|
'title' => $albumContent->model,
|
|
|
'category_id' => $mapping['base_product_category'],
|
|
|
+ 'sku' => $sku,
|
|
|
'content' => $content,
|
|
|
'created_at' => Carbon::now(),
|
|
|
'updated_at' => Carbon::now(),
|
|
@@ -80,6 +87,7 @@ class SyncAlbumContent extends Command
|
|
|
->update([
|
|
|
'title' => $albumContent->model,
|
|
|
'category_id' => $mapping['base_product_category'],
|
|
|
+ 'sku' => $sku,
|
|
|
'content' => $content,
|
|
|
'updated_at' => Carbon::now(),
|
|
|
]);
|