修复规格导入图片
This commit is contained in:
parent
395492c7b7
commit
4a57b4e344
@ -30,7 +30,7 @@ class Demo extends BaseController
|
|||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$mer_id = 36;
|
$mer_id = 104;
|
||||||
$file = request()->file('file');
|
$file = request()->file('file');
|
||||||
$zip_name = explode('.', $file->getOriginalName())[0];
|
$zip_name = explode('.', $file->getOriginalName())[0];
|
||||||
// 上传到本地服务器
|
// 上传到本地服务器
|
||||||
@ -136,11 +136,17 @@ class Demo extends BaseController
|
|||||||
Db::name('store_product')->where('product_id', $find['product_id'])->update($update);
|
Db::name('store_product')->where('product_id', $find['product_id'])->update($update);
|
||||||
/**更新规格图片 */
|
/**更新规格图片 */
|
||||||
foreach ($sku_arr as $k => $v) {
|
foreach ($sku_arr as $k => $v) {
|
||||||
$store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])->find();
|
$sku = explode(',', $k);
|
||||||
|
if(count($sku)==2){
|
||||||
|
$sku_name=$sku[0];
|
||||||
|
}else{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $sku_name])->find();
|
||||||
if ($store_product_attr_value) {
|
if ($store_product_attr_value) {
|
||||||
$oss = $upload->to($dir)->stream(file_get_contents($v));
|
$oss = $upload->to($dir)->stream(file_get_contents($v));
|
||||||
Db::name('store_product_attr_value')
|
Db::name('store_product_attr_value')
|
||||||
->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])
|
->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $sku_name])
|
||||||
->update(['image' => $oss->filePath]);
|
->update(['image' => $oss->filePath]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,9 +164,8 @@ class Demo extends BaseController
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$update_content['product_id'] = $find['product_id'];
|
$update_content['product_id'] = $find['product_id'];
|
||||||
$a=Db::name('store_product_content')
|
Db::name('store_product_content')
|
||||||
->insert(['product_id' => $find['product_id'], 'type' => 1, 'content' => json_encode($update_content)]);
|
->insert(['product_id' => $find['product_id'], 'type' => 1, 'content' => json_encode($update_content)]);
|
||||||
halt($a,2222);
|
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
halt($e->getMessage(), $e->getLine());
|
halt($e->getMessage(), $e->getLine());
|
||||||
|
@ -89,11 +89,17 @@ class ImportPicJob implements JobInterface
|
|||||||
Db::name('store_product')->where('product_id', $find['product_id'])->update($update);
|
Db::name('store_product')->where('product_id', $find['product_id'])->update($update);
|
||||||
/**更新规格图片 */
|
/**更新规格图片 */
|
||||||
foreach ($sku_arr as $k => $v) {
|
foreach ($sku_arr as $k => $v) {
|
||||||
$store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])->find();
|
$sku = explode(',', $k);
|
||||||
|
if(count($sku)==2){
|
||||||
|
$sku_name=$sku[0];
|
||||||
|
}else{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $sku_name])->find();
|
||||||
if ($store_product_attr_value) {
|
if ($store_product_attr_value) {
|
||||||
$oss = $upload->to($dir)->stream(file_get_contents($v));
|
$oss = $upload->to($dir)->stream(file_get_contents($v));
|
||||||
Db::name('store_product_attr_value')
|
Db::name('store_product_attr_value')
|
||||||
->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])
|
->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $sku_name])
|
||||||
->update(['image' => $oss->filePath]);
|
->update(['image' => $oss->filePath]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user