CsvImport: Parts: CVars von handle_cvars behandeln lassen.
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 11 Apr 2017 20:07:06 +0000 (22:07 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 6 Apr 2021 14:19:30 +0000 (16:19 +0200)
Dabei aber beachten, dass das bei einen Import, wo nur die Preise aktualisiert
werden sollen, nicht geschieht.

SL/Controller/CsvImport/Part.pm

index ecd212c..9afaf63 100644 (file)
@@ -175,7 +175,7 @@ sub check_objects {
     $self->handle_prices($entry) if $self->settings->{sellprice_adjustment};
     $self->handle_shoparticle($entry);
     $self->handle_translations($entry);
-    $self->handle_cvars($entry);
+    $self->handle_cvars($entry) unless $entry->{dont_handle_cvars};
     $self->handle_makemodel($entry);
     $self->set_various_fields($entry);
   } continue {
@@ -320,7 +320,8 @@ sub check_existing {
       $entry->{part}->prices(grep { $_ } map { $prices_by_pricegroup_id{$_->id} } @{ $self->all_pricegroups });
 
       push @{ $entry->{information} }, $::locale->text('Updating prices of existing entry in database');
-      $entry->{object_to_save} = $entry->{part};
+      $entry->{object_to_save}    = $entry->{part};
+      $entry->{dont_handle_cvars} = 1;
     } elsif ( $self->settings->{article_number_policy} eq 'update_parts' || $self->settings->{article_number_policy} eq 'update_parts_sn') {
 
       # Update parts table
@@ -355,24 +356,6 @@ sub check_existing {
       }
       $entry->{part}->translations(\@translations) if @translations;
 
-      # Update cvars
-      my %type_to_column = ( text      => 'text_value',
-                             textfield => 'text_value',
-                             select    => 'text_value',
-                             date      => 'timestamp_value_as_date',
-                             timestamp => 'timestamp_value_as_date',
-                             number    => 'number_value_as_number',
-                             bool      => 'bool_value' );
-      my @cvars;
-      push @cvars, $entry->{part}->custom_variables;
-      foreach my $config (@{ $self->all_cvar_configs }) {
-        next unless exists $raw->{ "cvar_" . $config->name };
-        my $value  = $raw->{ "cvar_" . $config->name };
-        my $column = $type_to_column{ $config->type } || die "Program logic error: unknown custom variable storage type";
-        push @cvars, SL::DB::CustomVariable->new(config_id => $config->id, $column => $value, sub_module => '');
-      }
-      $entry->{part}->custom_variables(\@cvars) if @cvars;
-
       # save Part Update
       push @{ $entry->{information} }, $::locale->text('Updating data of existing entry in database');