From 51c8535edb683d08420fd6bd6d083dae6a70cae0 Mon Sep 17 00:00:00 2001 From: fomichev Date: Thu, 28 Nov 2024 11:34:37 +0300 Subject: [PATCH] =?utf8?q?=D0=A4=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80?= =?utf8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/DataController.php | 49 ++++++++++------------- 1 file changed, 21 insertions(+), 28 deletions(-) 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)); } } } -- 2.39.5