Migx database CSV export edit titles and order [solved]

Good afternoon, I have a migxdb implementation running very well, it has an option in the manager area to “Export Current View” to an CSV file.
It’s exporting the file but the columns titles at the top are the same names and order that the database, normally the names in the database had no spaces or are not complete, they are just references, the question is:

Is it possible to rename and change the order of the columns in the CSV file? (obviously not after it’s exported, just in case!).

Thanks for your help, cheers! :+1:

Usually with MIGX you can customize the behavior by creating a custom processor. (Copy the default processor to the folder of your custom package and change the code).

For this, it’s either the “export” or “exportcsv” processor.
What Actionbutton are you using? “exportview” or “exportcsvmigxdb”?

I think, you can use a hooksnippet (getcustomconfigs)

which sets a exportfields config

I’m using: exportcsvmigxdb
Thinking that, is the right one to export the entire DB and not just what is in the screen!

I’ll try @bruno17 approach and let you all know.

Thanks for your advice. AS ALWAYS! :+1:

Well just to inform that I solved my problem.
In my case it’s only 1 table I need to export so I followed @halftrainedharry advice and modified the existing processor, in this case was: core/components/migx/processors/mgr/default/exportcsv.php

and the code I modified is:

    if ($header_row) {
        foreach ($array[0] as $key => $val) {
            //Escaping quotes.
            $key = str_replace($qut, "$qut$qut", $key);
            
            // ********  FIND AND REPLACE NAMES
            if ($key == "email") {
                $key = "Email";
            } elseif ($key == "firstname") {
                $key = "First Name";
            }
            // ******** FIND AND REPLACE NAMES
            
            $output .= "$col_sep$qut$key$qut";
        }
        $output = substr($output, 1) . $row_sep;
    }

It works just perfect. The order of the columns I did it directly modifying the table because I needed to add 1 extra field, so I just did it from there.

But thanks as always, problem solved! :+1: