Compare commits
2 Commits
e462b38ff9
...
f07741ff19
| Author | SHA1 | Date | |
|---|---|---|---|
| f07741ff19 | |||
| c64450d74c |
@@ -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('产品分类更新失败');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user