Support

Home Forums Event Espresso Premium CSV Export – Sort Order

CSV Export – Sort Order

Posted: September 21, 2017 at 7:03 am

Viewing 2 reply threads


sweetrose500

September 21, 2017 at 7:03 am

Hi – I’ve done some work to filter my CSV reports to show only certain data fields which has worked well.

How can I choose the default sort order for the document? It defaults to registration date and I’d like to sort by last name A –> Z without having to do this separately after the item is exported.

Additionally, is there any sorting available that would sort A –> Z except additional tickets? So, for example, if someone bought their own ticket plus 2 other tickets, they would be listed alphabetically and the 2 additional people would be listed under them regardless of alphabetical order?


Josh

  • Support Staff

September 21, 2017 at 10:53 am

Hi there,

In either case this is something that would require some PHP development. The simplest example would be the first option and order by last name:

add_filter('FHEE__EE_Export__report_registration_for_event', 'my_custom_report_query', 10, 2);

function my_custom_report_query($query_params, $event_id) {
  $query_params =
  array(
    array(
        'OR'  => array(
            'Transaction.STS_ID' => array(
                'NOT IN',
                array(
                    \EEM_Transaction::failed_status_code,
                    \EEM_Transaction::abandoned_status_code,
                ),
            ),
            'STS_ID'  => \EEM_Registration::status_id_approved,
        ),
        'Ticket.TKT_deleted' => array('IN', array(true, false)),
    ),
    'order_by'   => array('Attendee.ATT_lname' => 'asc', 'REG_count' => 'asc'),
    'force_join' => array('Transaction', 'Ticket', 'Attendee'),
    'caps'       => \EEM_Base::caps_read_admin,
  );
  return $query_params;
}

You can add the above to a functions plugin, then activate the plugin.


sweetrose500

September 21, 2017 at 11:03 am

Thanks

Viewing 2 reply threads

The support post ‘CSV Export – Sort Order’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso