Fixed: export CSV fields according to the selected Available Fields

Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
amit sharma
2026-07-14 15:20:24 +05:30
parent 5b4d65cbb8
commit 2462b6e1bd
3 changed files with 30 additions and 0 deletions

View File

@@ -1216,6 +1216,20 @@ class AdminControllerCore extends Controller
return;
}
if ((int)Configuration::get('PS_EXPORT_FIELDS_TYPE') === CSV::QLO_EXPORT_FIELDS_SELECTED) {
$list_visibility = json_decode($this->context->cookie->{'list_visibility_'.$this->context->controller->controller_name});
foreach ($this->fields_list as $key => $field) {
if (!isset($field['optional']) || !$field['optional']) {
continue;
}
$is_selected = (!is_array($list_visibility) && isset($field['visible_default']) && $field['visible_default'])
|| ($list_visibility && in_array($key, $list_visibility));
if (!$is_selected) {
unset($this->fields_list[$key]);
}
}
}
header('Content-type: text/csv');
header('Content-Type: application/force-download; charset=UTF-8');
header('Cache-Control: no-store, no-cache');