Commit 73c1fb7f by 杨树贤

sku描述图片批量替换

parent 63715f17
......@@ -116,8 +116,7 @@ class DealImageService
continue;
}
foreach ($itemList['data']['goods_id'] as $skuId) {
$skuDetail = DB::connection('mongodb')->table('sku_detail')->where('sku_id', (string)$skuId)->first();
dd($skuDetail);
$skuDetail = DB::connection('mongo')->table('sku_detail')->where('sku_id', (string)$skuId)->first();
$detail = $skuDetail['detail'];
if (empty($detail)) {
continue;
......@@ -129,24 +128,19 @@ class DealImageService
}
//dump($imageUrls); // 输出所有提取出的 'img.ichunt.com' 图片链接
$imageMap = self::downloadAndUploadToPicServer($imageUrls);
//进行全局替换
foreach ($imageMap as $originImage => $newImage) {
$detail = str_replace($originImage, $newImage, $detail);
}
//回写到mongo
DB::connection('mongo')->table('sku_detail')->where('sku_id', (string)$skuId)->update([
'update_time' => time(),
'detail' => $detail,
]);
$count++;
}
dump('已处理sku数量 : ' . $count);
}
dump('已处理sku数量 : ' . $count);
}
......
......@@ -357,7 +357,7 @@ return [
'strict' => false,
],
'mongodb' => [
'mongo' => [
'driver' => 'mongodb',
'host' => env('MONGO_HOST'),
'port' => 27017,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment