private function CSVIntroductionForm::reorderBasedOnPrefered in Commerce Smart Importer 8
Reorders labels.
1 call to CSVIntroductionForm::reorderBasedOnPrefered()
- CSVIntroductionForm::csvDownload in src/
Form/ CSVIntroductionForm.php - Downloads importer template.
File
- src/
Form/ CSVIntroductionForm.php, line 236
Class
- CSVIntroductionForm
- Introduction form.
Namespace
Drupal\commerce_smart_importer\FormCode
private function reorderBasedOnPrefered($labels) {
$identifier_fields = [
'SKU',
'ID(product)',
'ID(variation)',
];
$prefered_fields = [
'Title',
'Body',
'Price',
'Sale price',
'Currency',
'Image',
'Na stanju',
];
$identifiers = [];
$prefered = [];
$others = [];
foreach ($labels as $label) {
if (in_array($label, $identifier_fields)) {
$identifiers[] = $label;
}
elseif (in_array($label, $prefered_fields)) {
$prefered[] = $label;
}
else {
$others[] = $label;
}
}
return array_merge($identifiers, $prefered, $others);
}