moshaorui 4 months ago
parent
commit
3512098b24

+ 1 - 0
app/Console/Commands/ImportSpecificCategories.php

@@ -34,6 +34,7 @@ class ImportSpecificCategories extends Command
      */
     public function handle()
     {
+        exit;
         // 获取主类记录
         $mainCategories = DB::table('album_path')
             ->whereIn('name', ['功能类产品', '屏幕保护膜', '智能切膜机'])

+ 11 - 3
app/Console/Commands/SyncAlbumContent.php

@@ -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(),
                         ]);

+ 4 - 0
public/vendor/dcat-admin/dcat/css/dcatplus.css

@@ -1157,3 +1157,7 @@ body:not(.sidebar-mini-md) .content-wrapper, body:not(.sidebar-mini-md) .main-fo
     max-height: 80px;
     margin-top: -1px
 }
+
+.box-body img {
+    max-width: 100%;
+}