From 632b801d295afb811ae44514ddfc2fdb1eabc4e1 Mon Sep 17 00:00:00 2001 From: valentina Date: Thu, 18 Jul 2024 18:21:22 +0200 Subject: [PATCH] Fix import --- modules/anagrafiche/src/Import/CSV.php | 2 +- modules/articoli/src/Import/CSV.php | 4 ++-- modules/impianti/src/Import/CSV.php | 6 +++--- modules/interventi/src/Import/CSV.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/anagrafiche/src/Import/CSV.php b/modules/anagrafiche/src/Import/CSV.php index eba82beb2..9fa26b302 100644 --- a/modules/anagrafiche/src/Import/CSV.php +++ b/modules/anagrafiche/src/Import/CSV.php @@ -296,7 +296,7 @@ class CSV extends CSVImporter $database->insert('an_settori_lang', [ 'id_lang' => \Models\Locale::getDefault()->id, 'id_record' => $id_settore, - 'name' => $settore, + 'title' => $settore, ])['id']; } unset($record['id_settore']); diff --git a/modules/articoli/src/Import/CSV.php b/modules/articoli/src/Import/CSV.php index 29e3ff518..848f876f2 100644 --- a/modules/articoli/src/Import/CSV.php +++ b/modules/articoli/src/Import/CSV.php @@ -277,7 +277,7 @@ class CSV extends CSVImporter $sottocategoria = null; if (!empty($record['categoria'])) { // Categoria - $categoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['categoria'])))->orWhere('name', strtolower((string) $record['categoria']))->first(); + $categoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['categoria'])))->first(); if (empty($categoria)) { $categoria = Categoria::build(); @@ -287,7 +287,7 @@ class CSV extends CSVImporter // Sotto-categoria if (!empty($record['sottocategoria'])) { - $sottocategoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['sottocategoria'])))->orWhere('name', strtolower((string) $record['sottocategoria']))->first(); + $sottocategoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['sottocategoria'])))->first(); if (empty($sottocategoria)) { $sottocategoria = Categoria::build(); diff --git a/modules/impianti/src/Import/CSV.php b/modules/impianti/src/Import/CSV.php index e8abbfcae..3ae9a6f47 100644 --- a/modules/impianti/src/Import/CSV.php +++ b/modules/impianti/src/Import/CSV.php @@ -115,7 +115,7 @@ class CSV extends CSVImporter $sottocategoria = null; if (!empty($record['categoria'])) { // Categoria - $categoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['categoria'])))->orWhere('name', strtolower((string) $record['categoria']))->get()->id; + $categoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['categoria'])))->first(); if (empty($categoria)) { $categoria = Categoria::build(); @@ -125,7 +125,7 @@ class CSV extends CSVImporter // Sotto-categoria if (!empty($record['sottocategoria'])) { - $sottocategoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['sottocategoria'])))->orWhere('name', strtolower((string) $record['sottocategoria']))->get()->id; + $sottocategoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['sottocategoria'])))->first(); if (empty($sottocategoria)) { $sottocategoria = Categoria::build(); $sottocategoria->setTranslation('title', $record['sottocategoria']); @@ -168,7 +168,7 @@ class CSV extends CSVImporter $impianto->idanagrafica = $anagrafica->idanagrafica; $impianto->id_marca = $id_marca; - $impianto->modello = $record['modello']; + $impianto->id_modello = $record['modello']; $impianto->save(); if (!empty($record['sede'])) { diff --git a/modules/interventi/src/Import/CSV.php b/modules/interventi/src/Import/CSV.php index b43e48374..03c2c8f96 100644 --- a/modules/interventi/src/Import/CSV.php +++ b/modules/interventi/src/Import/CSV.php @@ -126,7 +126,7 @@ class CSV extends CSVImporter if (empty($record['stato'])) { $stato = Stato::where('name', 'Completato')->first(); } else { - $stato = Stato::where('name', $record['stato'])->first()->id; + $stato = Stato::where('name', $record['stato'])->first(); } unset($record['stato']);