]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-423 Api для отправки в 1с заказов
authormarina <m.zozirova@gmail.com>
Wed, 4 Jun 2025 07:49:06 +0000 (10:49 +0300)
committermarina <m.zozirova@gmail.com>
Wed, 4 Jun 2025 07:49:06 +0000 (10:49 +0300)
erp24/api2/controllers/OrdersController.php

index ee41a8948150d2c60e25a36bc0df50abf7990198..1f6f09dc58386b3574157ec6b8d36adb6b7f9696 100644 (file)
@@ -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,
                 ];
             }