在app/services/product/product/StoreProductServices.php文件中
修改红框内代码
//采集商品下载图片
if ($type == -1) {
$s_image_down = [];
//下载商品轮播图
foreach ($slider_image as $s_image) {
if (sys_config('queue_open', 0) == 1) {
ProductCopyJob::dispatch('copySliderImage', [$res->id, $s_image, count($slider_image)]);
} else {
//下载图片
$s_image_down[] = app()->make(CopyTaobaoServices::class)->downloadCopyImage($s_image);
}
}
//下载商品详情图
preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $description, $match);
foreach ($match[1] as $d_image) {
if (sys_config('queue_open', 0) == 1) {
ProductCopyJob::dispatch('copyDescriptionImage', [$res->id, $description, $d_image, count($match[1])]);
} else {
$d_img = app()->make(CopyTaobaoServices::class)->downloadCopyImage(!is_int(strpos($d_image, 'http')) ? 'http://' . ltrim($d_image, '\//') : $d_image);
$description = str_replace($d_image, $d_img, $description);
}
}
if (sys_config('queue_open', 0) == 0) {
$this->update($res->id, ['slider_image' => $s_image_down ? json_encode($s_image_down) : '', 'image' => $s_image_down[0]]);
app()->make(StoreProductAttrValueServices::class)->update(['product_id' => $res->id], ['image' => $s_image_down[0]]);
$storeDescriptionServices->saveDescription((int)$res->id, $description);
}
}
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}