fix: admapi - 产品目录同步分类更新时bug修复

This commit is contained in:
2025-08-07 17:07:48 +08:00
parent f9445b6f49
commit 4872574eb0

View File

@@ -99,6 +99,7 @@ class ReceiveProductSync
} }
$category = ProductCategoryModel::language($lang_id)->tcoId($tco_category['id'])->find(); $category = ProductCategoryModel::language($lang_id)->tcoId($tco_category['id'])->find();
if (!empty($category)) {
$tco_parent = ProductTcoCategoryModel::language($lang_id)->tcoId($tco_category['tco_pid'])->find(); $tco_parent = ProductTcoCategoryModel::language($lang_id)->tcoId($tco_category['tco_pid'])->find();
if (!empty($tco_parent)) { if (!empty($tco_parent)) {
$parent = ProductCategoryModel::language($lang_id)->tcoId($tco_parent['id'])->find(); $parent = ProductCategoryModel::language($lang_id)->tcoId($tco_parent['id'])->find();
@@ -109,10 +110,11 @@ class ReceiveProductSync
$category['path'] = $parent['path'] . $parent['pid']; $category['path'] = $parent['path'] . $parent['pid'];
$category['level'] = $parent['level'] + 1; $category['level'] = $parent['level'] + 1;
} }
if (!$category->save($category)) { if (!$category->save()) {
throw new \Exception('产品分类更新失败'); throw new \Exception('产品分类更新失败');
} }
} }
}
Db::commit(); Db::commit();
} catch (\Throwable $th) { } catch (\Throwable $th) {