]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix(ERP-292): type cast и null guard в AutoMarkService
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 17 Apr 2026 13:55:22 +0000 (16:55 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 17 Apr 2026 13:55:22 +0000 (16:55 +0300)
erp24/services/AutoMarkService.php

index d1f9e502185266f4187be12268fb9acaadcf0dd2..b524372b0cabf5b54db95c2e4a781b31d084fbe7 100644 (file)
@@ -64,10 +64,13 @@ class AutoMarkService
 
         $nomenclature = Products1cNomenclature::findOne($prediction->product_id);
         if ($nomenclature === null) {
-            $nomenclature     = new Products1cNomenclature();
-            $nomenclature->id = $prediction->product_id;
             $product = Products1c::findOne($prediction->product_id);
-            $nomenclature->name     = $product?->name ?? '';
+            if ($product === null) {
+                return false;
+            }
+            $nomenclature          = new Products1cNomenclature();
+            $nomenclature->id      = $prediction->product_id;
+            $nomenclature->name    = $product->name;
             $nomenclature->location = '';
             $nomenclature->type_num = '';
         }
@@ -96,7 +99,7 @@ class AutoMarkService
 
         $count = 0;
         foreach ($productIds as $id) {
-            if ($this->predictForProduct($id) !== null) {
+            if ($this->predictForProduct((string) $id) !== null) {
                 $count++;
             }
         }