Download csv

How to fix CSV download showing "Array" instead of values in Excel.

Overview

The issue occurs because the data provider references a nested array structure incorrectly.
Adjust the data provider path to point directly to the field values, not the parent array, and use the full server path instead of the {path:front} placeholder for the file save location.

Answered
Connectivity v6
we webcrea 13 Feb, 2019
Hi,

When i use download csv
Data providr = {var:read_enrollments_export}

i see in excel

enrollment | ID | First name | Last name
Array
Array
Array
Array
Array

enrollment is the model name in the read_data
it seams to find array where it should find value...

debug:
Array
(
    [read_enrollments_export] => Array
        (
            [log] => Array
                (
                    [0] => SELECT `enrollment`.`id` AS `enrollment.id`, `enrollment`.`student_first_name` AS `enrollment.student_first_name`, `enrollment`.`student_last_name` AS `enrollment.student_last_name` FROM `skf0d_admincrm_enrollments` AS `enrollment` WHERE `enrollment`.`sessions_id` = '290' LIMIT 100;
                )

            [var] => Array
                (
                    [0] => Array
                        (
                            [enrollment] => Array
                                (
                                    [id] => 3187
                                    [student_first_name] => Liying
                                    [student_last_name] => An
                                )

                        )

                    [1] => Array
                        (
                            [enrollment] => Array
                                (
                                    [id] => 3188
                                    [student_first_name] => Zhen
                                    [student_last_name] => Chao
                                )

                        )

                    [2] => Array
                        (
                            [enrollment] => Array
                                (
                                    [id] => 3189
                                    [student_first_name] => An Qi
                                    [student_last_name] => Xie
                                )
etc...

there are 5 line matches the count, it's ok.

Thanks
we webcrea 14 Feb, 2019
Thanks for your help

Store file doesn't work, i have an error
Error saving the csv file.

The path exists, directory in 777
{path:front}/uploads/enrollments/enrollments_export.csv

Do you have any idea ?
Regards
he healyhatman 14 Feb, 2019
Shouldn't it be 755? 777 is a bit too permissive right?

But I don't know what the deal is sorry. Just tested it and it works for me, so probably just make sure the folders actually exist.
we webcrea 14 Feb, 2019
Answer
Don't use {path:front}
With the real path it works...
Thanks
This topic is locked and no more replies can be posted.