From: fomichev Date: Thu, 28 Nov 2024 08:34:37 +0000 (+0300) Subject: Форматирование X-Git-Tag: 1.7~212^2~6 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=51c8535edb683d08420fd6bd6d083dae6a70cae0;p=erp24_rep%2Fyii-erp24%2F.git Форматирование --- diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index 338c76be..d8b43180 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -577,46 +577,37 @@ class DataController extends BaseController { } if (!empty($arr["AdditionCharacteristics"])) { - - - $passedCharacteristics = array_column($arr["AdditionCharacteristics"], null, "id"); - - - $currentCharacteristics = Products1cAdditionalCharacteristics::find() - ->where(['product_id' => $arr["id"]]) - ->indexBy('property_id') - ->all(); - - - foreach ($currentCharacteristics as $propertyId => $currentCharacteristic) { - if (!isset($passedCharacteristics[$propertyId])) { - - if (!$currentCharacteristic->delete()) { - LogService::apiErrorLog(json_encode([ - "error_id" => 8.3, - "error" => $currentCharacteristic->getErrors() - ], JSON_UNESCAPED_UNICODE)); - } + $passedCharacteristics = array_column($arr["AdditionCharacteristics"], null, "id"); + $currentCharacteristics = Products1cAdditionalCharacteristics::find() + ->where(['product_id' => $arr["id"]]) + ->indexBy('property_id') + ->all(); + + foreach ($currentCharacteristics as $propertyId => $currentCharacteristic) { + if (!isset($passedCharacteristics[$propertyId])) { + if (!$currentCharacteristic->delete()) { + LogService::apiErrorLog(json_encode([ + "error_id" => 8.3, + "error" => $currentCharacteristic->getErrors() + ], JSON_UNESCAPED_UNICODE)); } } + } - - - - foreach ($arr["AdditionCharacteristics"] as $characteristic) { - + foreach ($arr["AdditionCharacteristics"] as $characteristic) { $propertyType = Products1cPropType::findOne(['id' => $characteristic["id"]]); if (!$propertyType) { $propertyType = new Products1cPropType(); $propertyType->id = $characteristic["id"]; $propertyType->name = $characteristic["name"]; if (!$propertyType->save()) { - LogService::apiErrorLog(json_encode(["error_id" => 8.1, "error" => $propertyType->getErrors()], JSON_UNESCAPED_UNICODE)); + LogService::apiErrorLog(json_encode(["error_id" => 8.1, + "error" => $propertyType->getErrors()], + JSON_UNESCAPED_UNICODE)); continue; } } - $additionalCharacteristic = Products1cAdditionalCharacteristics::findOne([ 'product_id' => $arr["id"], 'property_id' => $characteristic["id"] @@ -630,7 +621,9 @@ class DataController extends BaseController { $additionalCharacteristic->value = $characteristic["value_name"]; if (!$additionalCharacteristic->save()) { - LogService::apiErrorLog(json_encode(["error_id" => 8.2, "error" => $additionalCharacteristic->getErrors()], JSON_UNESCAPED_UNICODE)); + LogService::apiErrorLog(json_encode(["error_id" => 8.2, + "error" => $additionalCharacteristic->getErrors()], + JSON_UNESCAPED_UNICODE)); } } }