Apply report controller default parameters for CSV export.
This commit is contained in:
parent
c13d35c68a
commit
83c8f756d8
|
@ -155,7 +155,17 @@ class WC_Admin_Report_CSV_Exporter extends WC_CSV_Batch_Exporter {
|
||||||
* Prepare data for export.
|
* Prepare data for export.
|
||||||
*/
|
*/
|
||||||
public function prepare_data_to_export() {
|
public function prepare_data_to_export() {
|
||||||
$request = new WP_REST_Request( 'GET', "/wc/v4/reports/{$this->report_type}" );
|
$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 );
|
$request->set_query_params( $this->report_args );
|
||||||
|
|
||||||
$response = $this->controller->get_items( $request );
|
$response = $this->controller->get_items( $request );
|
||||||
|
|
Loading…
Reference in New Issue