Merge branch 'dev'

This commit is contained in:
2025-08-07 17:08:12 +08:00

View File

@@ -99,18 +99,20 @@ class ReceiveProductSync
} }
$category = ProductCategoryModel::language($lang_id)->tcoId($tco_category['id'])->find(); $category = ProductCategoryModel::language($lang_id)->tcoId($tco_category['id'])->find();
$tco_parent = ProductTcoCategoryModel::language($lang_id)->tcoId($tco_category['tco_pid'])->find(); if (!empty($category)) {
if (!empty($tco_parent)) { $tco_parent = ProductTcoCategoryModel::language($lang_id)->tcoId($tco_category['tco_pid'])->find();
$parent = ProductCategoryModel::language($lang_id)->tcoId($tco_parent['id'])->find(); if (!empty($tco_parent)) {
if ($parent->isEmpty()) { $parent = ProductCategoryModel::language($lang_id)->tcoId($tco_parent['id'])->find();
throw new \Exception('产品分类父级不存在'); if ($parent->isEmpty()) {
throw new \Exception('产品分类父级不存在');
}
$category['pid'] = $parent['id'];
$category['path'] = $parent['path'] . $parent['pid'];
$category['level'] = $parent['level'] + 1;
}
if (!$category->save()) {
throw new \Exception('产品分类更新失败');
} }
$category['pid'] = $parent['id'];
$category['path'] = $parent['path'] . $parent['pid'];
$category['level'] = $parent['level'] + 1;
}
if (!$category->save($category)) {
throw new \Exception('产品分类更新失败');
} }
} }