Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d85c9c95

Von Tamino Steinert vor 5 Monaten hinzugefügt

  • ID d85c9c95d15706e82ff0c34debc32c1460536678
  • Vorgänger 1c54dd60
  • Nachfolger e01884e2

Varianten: Helferfunktion zum Sortieren von Varianten eines Stammartikel

Unterschiede anzeigen:

SL/Controller/Part.pm
945 945
    lastcost         => sub { $_[0]->lastcost },
946 946
    onhand           => sub { $_[0]->onhand },
947 947
    rop              => sub { $_[0]->rop },
948
    variant_values   => sub { $_[0]->variant_values },
948
    variant_values   => sub { $_[0]->variant_values_sortkey },
949 949
  );
950 950
  foreach my $variant_property (@{$part->variant_properties}) {
951 951
    my $key = 'variant_property_' . $variant_property->id;
SL/DB/Manager/Part.pm
259 259
    sort { $a->{sortkey} cmp $b->{sortkey} }
260 260
    map { {
261 261
      variant => $_,
262
      sortkey => join('', map {
263
          (10000 + $_->variant_property->sortkey ) . (10000 + $_->sortkey)
264
        } @{$_->variant_property_values}
265
      ),
266

  
262
      sortkey => $_->variant_values_sortkey,
267 263
    } }
268 264
    @$variants;
269 265
  return \@sorted_variants;
SL/DB/Part.pm
748 748
  )  . "]";
749 749
}
750 750

  
751
sub variant_values_sortkey {
752
  my ($self) = @_;
753
  join('',
754
    map { (10000 + $_->variant_property->sortkey ) . (10000 + $_->sortkey) }
755
    sort { $a->variant_property->sortkey <=> $b->variant_property->sortkey }
756
    @{$self->variant_property_values}
757
  )
758
};
759

  
751 760
sub variant_value {
752 761
  my ($self, $variant_property) = @_;
753 762
  die "only callable on parts of type parent_variant"     unless $self->is_variant;

Auch abrufbar als: Unified diff