Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 98404f3e

Von Tamino Steinert vor 8 Monaten hinzugefügt

  • ID 98404f3ed037c375e08c54579a5d1dad44574b12
  • Vorgänger 59661dc5
  • Nachfolger fc6a3e79

Varianten: PartPicker: mehrere Varianten eines Stammartikel hinzufügen

Unterschiede anzeigen:

SL/DB/Manager/Part.pm
34 34
    return or => [ map { $prefix . $_ => $value } qw(partnumber description ean customerprices.customer_partnumber) ],
35 35
      $prefix . 'customerprices';
36 36
  },
37
  has_variant_property_value_id => sub {
38
    my ($key, $value, $prefix) = @_;
39

  
40
    my @values = grep {$_}
41
      ref $value eq 'ARRAY' ? @{$value} : split(/\s+/, $value);
42
    return unless scalar @values;
43

  
44
    my $where = join(' or ', ("val.id = ?") x @values) || '1=1';
45
    my $query = <<SQL;
46
      SELECT part_id from (
47
        SELECT
48
          t1.part_id, COUNT(*) as count_hits
49
        FROM
50
          variant_property_values val
51
          JOIN variant_property_values_parts t1 ON (t1.variant_property_value_id = val.id)
52
        WHERE
53
         $where
54
        GROUP BY t1.part_id
55
      ) as tmp
56
      WHERE count_hits >= ?;
57
SQL
58

  
59
    push @values, scalar @values; # count_hits
60

  
61
    my @part_ids =
62
      map {$_->{part_id}}
63
      selectall_hashref_query($::form, $::form->get_standard_dbh, $query, @values);
64

  
65
    return id => scalar @part_ids ? \@part_ids : (-1); # empty list not allowed
66
  },
37 67
  # all_with_variants => sub {
38 68
  all => sub {
39 69
    my ($key, $value, $prefix) = @_;
......
221 251
  return $open_qty
222 252
}
223 253

  
254
sub sort_variants {
255
  my ($self, $variants) = @_;
256

  
257
  my @sorted_variants =
258
    map { $_->{variant} }
259
    sort { $a->{sortkey} cmp $b->{sortkey} }
260
    map { {
261
      variant => $_,
262
      sortkey => join('', map {
263
          (10000 + $_->variant_property->sortkey ) . (10000 + $_->sortkey)
264
        } @{$_->variant_property_values}
265
      ),
266

  
267
    } }
268
    @$variants;
269
  return \@sorted_variants;
270
}
271

  
224 272
sub _sort_spec {
225 273
  (
226 274
    default  => [ 'partnumber', 1 ],

Auch abrufbar als: Unified diff