From ece90f1be09cb91f65f4458c8a4d35a6b17d65d2 Mon Sep 17 00:00:00 2001 From: marina Date: Wed, 4 Jun 2025 10:49:06 +0300 Subject: [PATCH] =?utf8?q?ERP-423=20Api=20=D0=B4=D0=BB=D1=8F=20=D0=BE?= =?utf8?q?=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B2=201=D1=81=20?= =?utf8?q?=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/OrdersController.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/erp24/api2/controllers/OrdersController.php b/erp24/api2/controllers/OrdersController.php index ee41a894..1f6f09dc 100644 --- a/erp24/api2/controllers/OrdersController.php +++ b/erp24/api2/controllers/OrdersController.php @@ -218,19 +218,24 @@ class OrdersController extends BaseController $result = []; foreach ($orders as $order) { - $orderProducts = []; + $products = []; + $productsWithoutGuid = []; foreach ($order->items as $product) { - $product1c = Products1c::findOne(['articule' => $product->shop_sku])->id ?? null; - $orderProducts[] = [ - $product1c => $product->count - ]; + $product1c = Products1c::findOne(['articule' => $product->offer_id]); + + if ($product1c) { + $products[$product1c->id] = $product->count; + } else { + $productsWithoutGuid[$product->offer_name] = $product->count; + } } $result[] = [ 'order_id' => $order->guid, 'status' => $order->status_id, - 'products' => $orderProducts, + 'products' => $products, + 'products_without_guid' => $productsWithoutGuid, ]; } -- 2.39.5