This commit is contained in:
2025-12-16 13:41:03 +08:00
parent 314d395f80
commit 4583b98618
+6 -2
View File
@@ -89,7 +89,6 @@ class SkuController extends BaseController
public function import(Request $request) public function import(Request $request)
{ {
$file = $request->file('file'); $file = $request->file('file');
if (!$file) return $this->error('未上传文件');; if (!$file) return $this->error('未上传文件');;
@@ -161,7 +160,12 @@ class SkuController extends BaseController
$skuAttribute = SkuAttribute::where('attr_name', $item[0]) $skuAttribute = SkuAttribute::where('attr_name', $item[0])
->where('category_id', $data['category_id'])->first(); ->where('category_id', $data['category_id'])->first();
if (empty($skuAttribute)) { if (empty($skuAttribute)) {
continue; $skuAttribute = SkuAttribute::create([
'attr_name' => $item[0],
'attr_value' => $item[1],
'category_id' => $data['category_id'],
'attr_type' => 'text'
]);
} }
$attr['attr_id'] = $skuAttribute->id; $attr['attr_id'] = $skuAttribute->id;
$attr['category_id'] = $data['category_id']; $attr['category_id'] = $data['category_id'];