Apply report controller default parameters for CSV export.

This commit is contained in:
Jeff Stieler 2019-06-24 12:57:07 -06:00
parent c13d35c68a
commit 83c8f756d8
1 changed files with 11 additions and 1 deletions

View File

@ -156,6 +156,16 @@ class WC_Admin_Report_CSV_Exporter extends WC_CSV_Batch_Exporter {
*/
public function prepare_data_to_export() {
$request = new WP_REST_Request( 'GET', "/wc/v4/reports/{$this->report_type}" );
$params = $this->controller->get_collection_params();
$defaults = array();
foreach ( $params as $arg => $options ) {
if ( isset( $options['default'] ) ) {
$defaults[ $arg ] = $options['default'];
}
}
$request->set_default_params( $defaults );
$request->set_query_params( $this->report_args );
$response = $this->controller->get_items( $request );