Revision ae781cce
Von Tamino Steinert vor 6 Tagen hinzugefügt
scripts/import_variant_csv.pl | ||
---|---|---|
302 | 302 |
$variant_property->save; |
303 | 303 |
|
304 | 304 |
my $pos = 1; |
305 |
SL::DB::VariantPropertyValue->new( |
|
306 |
variant_property => $variant_property, |
|
307 |
value => $_->{Joined}, |
|
308 |
abbreviation => $_->{Joined}, |
|
309 |
)->update_attributes( |
|
310 |
sortkey => $pos++, |
|
311 |
)->save for @$farb_hrefs; |
|
305 |
foreach my $farb_row (@$farb_hrefs) { |
|
306 |
my %farb_attr = ( |
|
307 |
variant_property_id => $variant_property->id, |
|
308 |
value => $farb_row->{Joined}, |
|
309 |
abbreviation => $farb_row->{Joined}, |
|
310 |
); |
|
311 |
my $farbe = SL::DB::Manager::VariantPropertyValue->find_by( |
|
312 |
%farb_attr |
|
313 |
); |
|
314 |
$farbe ||= SL::DB::VariantPropertyValue->new( |
|
315 |
%farb_attr |
|
316 |
)->save; |
|
317 |
$farbe->update_attributes( |
|
318 |
sortkey => $pos++, |
|
319 |
); |
|
320 |
} |
|
312 | 321 |
} |
313 | 322 |
|
314 | 323 |
# create groessen staffeln |
... | ... | |
327 | 336 |
); |
328 | 337 |
$variant_property->save; |
329 | 338 |
|
330 |
my $pos = 1; |
|
331 |
SL::DB::VariantPropertyValue->new( |
|
332 |
variant_property => $variant_property, |
|
333 |
value => $_, |
|
334 |
abbreviation => $_, |
|
335 |
)->update_attributes( |
|
336 |
sortkey => $pos++, |
|
337 |
)->save for |
|
339 |
my @values = |
|
338 | 340 |
map {$groessen_staffel_row->{$_}} |
339 | 341 |
sort |
340 | 342 |
grep {$groessen_staffel_row->{$_} ne ''} |
341 | 343 |
keys %$groessen_staffel_row; |
344 |
my $pos = 1; |
|
345 |
foreach my $value (@values) { |
|
346 |
my %größe_attr = ( |
|
347 |
variant_property_id => $variant_property->id, |
|
348 |
value => $value, |
|
349 |
abbreviation => $value, |
|
350 |
); |
|
351 |
my $größe = SL::DB::Manager::VariantPropertyValue->find_by( |
|
352 |
%größe_attr |
|
353 |
); |
|
354 |
$größe ||= SL::DB::VariantPropertyValue->new( |
|
355 |
%größe_attr |
|
356 |
)->save; |
|
357 |
$größe->update_attributes( |
|
358 |
sortkey => $pos++, |
|
359 |
); |
|
360 |
} |
|
342 | 361 |
} |
343 | 362 |
|
344 | 363 |
# create partsgroups |
Auch abrufbar als: Unified diff
kuw: FIX: CSV-Import-Script: Ausprägungen nicht mehrfach anlegen