diff --git a/classes/CSV.php b/classes/CSV.php index a1f785087..bb75087eb 100644 --- a/classes/CSV.php +++ b/classes/CSV.php @@ -31,9 +31,6 @@ */ class CSVCore { - const QLO_EXPORT_FIELDS_ALL = 0; - const QLO_EXPORT_FIELDS_SELECTED = 1; - public $filename; public $collection; public $delimiter; diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 55e37d4c4..2d6c60b28 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1211,18 +1211,26 @@ class AdminControllerCore extends Controller if (ob_get_level() && ob_get_length() > 0) { ob_clean(); } + $base_fields_list = $this->fields_list; + $this->getList($this->context->language->id, null, null, 0, false); if (!count($this->_list)) { return; } - if ((int)Configuration::get('PS_EXPORT_FIELDS_TYPE') === CSV::QLO_EXPORT_FIELDS_SELECTED) { + if ((int)Configuration::get('PS_EXPORT_FIELDS_TYPE') === HelperList::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']) { + $reference_field = isset($base_fields_list[$key]) ? $base_fields_list[$key] : $field; + + if (isset($reference_field['displayed']) && !$reference_field['displayed']) { + unset($this->fields_list[$key]); continue; } - $is_selected = (!is_array($list_visibility) && isset($field['visible_default']) && $field['visible_default']) + if ((!isset($reference_field['optional']) || !$reference_field['optional']) && isset($base_fields_list[$key])) { + continue; + } + $is_selected = (!is_array($list_visibility) && isset($reference_field['visible_default']) && $reference_field['visible_default']) || ($list_visibility && in_array($key, $list_visibility)); if (!$is_selected) { unset($this->fields_list[$key]); diff --git a/classes/helper/HelperList.php b/classes/helper/HelperList.php index 5e0a4e76f..b5fbd344b 100644 --- a/classes/helper/HelperList.php +++ b/classes/helper/HelperList.php @@ -29,6 +29,8 @@ */ class HelperListCore extends Helper { + const QLO_EXPORT_FIELDS_ALL = 0; + const QLO_EXPORT_FIELDS_SELECTED = 1; /** * @var int|null */ diff --git a/controllers/admin/AdminPreferencesController.php b/controllers/admin/AdminPreferencesController.php index 3b6e866e9..4ceb3f0f5 100644 --- a/controllers/admin/AdminPreferencesController.php +++ b/controllers/admin/AdminPreferencesController.php @@ -202,11 +202,11 @@ class AdminPreferencesControllerCore extends AdminController 'cast' => 'intval', 'type' => 'select', 'list' => array( - array('id' => CSV::QLO_EXPORT_FIELDS_ALL, 'name' => $this->l('All Fields')), - array('id' => CSV::QLO_EXPORT_FIELDS_SELECTED, 'name' => $this->l('Selected Fields')), + array('id' => HelperList::QLO_EXPORT_FIELDS_ALL, 'name' => $this->l('All Fields')), + array('id' => HelperList::QLO_EXPORT_FIELDS_SELECTED, 'name' => $this->l('Selected Fields')), ), 'identifier' => 'id', - 'defaultValue' => CSV::QLO_EXPORT_FIELDS_ALL, + 'defaultValue' => HelperList::QLO_EXPORT_FIELDS_ALL, ), // 'PS_DISPLAY_SUPPLIERS' => array( // 'title' => $this->l('Display suppliers and manufacturers'),