From 8bb03984cd6d9e898abce433ce92f8cad05056a0 Mon Sep 17 00:00:00 2001 From: Beppe Date: Fri, 2 Oct 2020 16:45:09 +0200 Subject: [PATCH] Fix importazione categorie articoli --- modules/articoli/src/Import/CSV.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/articoli/src/Import/CSV.php b/modules/articoli/src/Import/CSV.php index 9163f9ee8..f98c8dc43 100644 --- a/modules/articoli/src/Import/CSV.php +++ b/modules/articoli/src/Import/CSV.php @@ -82,7 +82,7 @@ class CSV extends CSVImporter ], ], [ - 'field' => 'categoria', + 'field' => 'id_categoria', 'label' => 'Categoria', 'names' => [ 'Categoria', @@ -91,7 +91,7 @@ class CSV extends CSVImporter ], ], [ - 'field' => 'sottocategoria', + 'field' => 'id_sottocategoria', 'label' => 'Sottocategoria', 'names' => [ 'Sottocategoria', @@ -147,29 +147,29 @@ class CSV extends CSVImporter } // Gestione categoria e sottocategoria - if (!empty($record['categoria'])) { + if (!empty($record['id_categoria'])) { // Categoria - $categoria = Categoria::where('nome', $record['categoria'])->first(); + $categoria = Categoria::where('nome', $record['id_categoria'])->first(); if (empty($categoria)) { - $categoria = Categoria::build($record['categoria']); + $categoria = Categoria::build($record['id_categoria']); } // Sotto-categoria $sottocategoria = null; - if (!empty($record['sottocategoria'])) { - $sottocategoria = Categoria::where('nome', $record['sottocategoria']) + if (!empty($record['id_sottocategoria'])) { + $sottocategoria = Categoria::where('nome', $record['id_sottocategoria']) ->where('parent', $categoria->id) ->first(); if (empty($sottocategoria)) { - $sottocategoria = Categoria::build($record['categoria']); + $sottocategoria = Categoria::build($record['id_categoria']); $sottocategoria->parent()->associate($categoria); $sottocategoria->save(); } } } - unset($record['categoria']); - unset($record['sottocategoria']); + unset($record['id_categoria']); + unset($record['id_sottocategoria']); // Individuazione dell'IVA di vendita tramite il relativo Codice $aliquota = null;