$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 = '';
}
$count = 0;
foreach ($productIds as $id) {
- if ($this->predictForProduct($id) !== null) {
+ if ($this->predictForProduct((string) $id) !== null) {
$count++;
}
}