From 85f9e4958564847dc9917345b0437c013a77a6d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 12 Dec 2014 17:20:32 +0100 Subject: [PATCH] CsvImport: Makemodels auch auf instabilen Datenbanken in der richtigen Reihenfolge speichern --- SL/Controller/CsvImport/Part.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SL/Controller/CsvImport/Part.pm b/SL/Controller/CsvImport/Part.pm index 9f4ed7284..33301d140 100644 --- a/SL/Controller/CsvImport/Part.pm +++ b/SL/Controller/CsvImport/Part.pm @@ -428,6 +428,7 @@ sub handle_makemodel { } my %old_makemodels_by_mm = map { $_->make . $; . $_->model => $_ } $entry->{part}->makemodels; + my @new_makemodels; foreach my $makemodel ($object->makemodels()) { my $makemodel_orig = $old_makemodels_by_mm{$makemodel->make,$makemodel->model}; @@ -438,10 +439,12 @@ sub handle_makemodel { $makemodel_orig->lastcost($makemodel->lastcost); } else { - $entry->{part}->add_makemodels($makemodel); + push @new_makemodels, $makemodel; } } + $entry->{part}->makemodels([ $entry->{part}->makemodels, @new_makemodels ]) if @new_makemodels; + # reindex makemodels my $i = 0; $_->sortorder(++$i) for @{ $entry->{part}->makemodels }; -- 2.20.1