正在显示
1 个修改的文件
包含
15 行增加
和
17 行删除
| @@ -80,24 +80,22 @@ class UpdateSeoTdk extends Command | @@ -80,24 +80,22 @@ class UpdateSeoTdk extends Command | ||
| 80 | if(!empty($list)){ | 80 | if(!empty($list)){ |
| 81 | foreach ($list as $v){ | 81 | foreach ($list as $v){ |
| 82 | $v = (array)$v; | 82 | $v = (array)$v; |
| 83 | - if(!empty($v['seo_mate'])){ | ||
| 84 | - $seo_arr = json_decode($v['seo_mate'], true); | ||
| 85 | - //更新seo_title | ||
| 86 | - if(!isset($seo_arr['title'])){ | ||
| 87 | - //生成seo_title | ||
| 88 | - $seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']); | ||
| 89 | - } | ||
| 90 | - //更新seo_keyword | ||
| 91 | - if(!isset($seo_arr['keyword'])){ | ||
| 92 | - $seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']); | ||
| 93 | - } | ||
| 94 | - //更新seo_keyword | ||
| 95 | - if(!isset($seo_arr['description'])){ | ||
| 96 | - $seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']); | ||
| 97 | - } | ||
| 98 | - $ser_str = json_encode($seo_arr,true); | ||
| 99 | - DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]); | 83 | + $seo_arr = json_decode($v['seo_mate'], true) ?: []; |
| 84 | + //更新seo_title | ||
| 85 | + if(!isset($seo_arr['title'])){ | ||
| 86 | + //生成seo_title | ||
| 87 | + $seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']); | ||
| 100 | } | 88 | } |
| 89 | + //更新seo_keyword | ||
| 90 | + if(!isset($seo_arr['keyword'])){ | ||
| 91 | + $seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']); | ||
| 92 | + } | ||
| 93 | + //更新seo_keyword | ||
| 94 | + if(!isset($seo_arr['description'])){ | ||
| 95 | + $seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']); | ||
| 96 | + } | ||
| 97 | + $ser_str = json_encode($seo_arr,true); | ||
| 98 | + DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]); | ||
| 101 | } | 99 | } |
| 102 | } | 100 | } |
| 103 | return true; | 101 | return true; |
-
请 注册 或 登录 后发表评论