Revision 5a6615ed
Von Tamino Steinert vor 6 Tagen hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
952 | 952 |
lastcost => sub { $_[0]->lastcost }, |
953 | 953 |
onhand => sub { $_[0]->onhand }, |
954 | 954 |
rop => sub { $_[0]->rop }, |
955 |
variant_values => sub { $_[0]->variant_values }, |
|
955 |
variant_values => sub { $_[0]->variant_values_sortkey },
|
|
956 | 956 |
); |
957 | 957 |
foreach my $variant_property (@{$part->variant_properties}) { |
958 | 958 |
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
Varianten: Helferfunktion zum Sortieren von Varianten eines Stammartikel