refactor: 修改产品属性类型

This commit is contained in:
2025-02-12 17:58:53 +08:00
parent feb0b92bd0
commit f20325b220
6 changed files with 19 additions and 15 deletions

View File

@@ -74,6 +74,7 @@ class ProductAttr
public function save()
{
$post = request()->post([
'attr_type' => 2,
'attr_name' => '',
'is_system' => 0,
]);
@@ -100,13 +101,15 @@ class ProductAttr
}
// 添加属性特征
foreach ($props as &$prop) {
$prop['attr_id'] = $attr_ret->id;
}
unset($prop);
$props_ret = (new ProductAttrPropModel)->saveAll($props);
if ($props_ret->isEmpty()) {
throw new \Exception("操作失败");
if (!empty($props)) {
foreach ($props as &$prop) {
$prop['attr_id'] = $attr_ret->id;
}
unset($prop);
$props_ret = (new ProductAttrPropModel)->saveAll($props);
if ($props_ret->isEmpty()) {
throw new \Exception("操作失败");
}
}
ProductAttrModel::commit();
@@ -125,7 +128,8 @@ class ProductAttr
{
$id = request()->param('id');
$put = request()->put([
'attr_name' => '',
'attr_type',
'attr_name',
'is_system' => 0,
]);
$attr = array_merge($put, ['language_id' => request()->lang_id]);