Query.php
61 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class for parameter-based Variations Stats Report querying |
| 4 | * |
| 5 | * Example usage: |
| 6 | * $args = array( |
| 7 | * 'before' => '2018-07-19 00:00:00', |
| 8 | * 'after' => '2018-07-05 00:00:00', |
| 9 | * 'page' => 2, |
| 10 | * 'categories' => array(15, 18), |
| 11 | * 'product_ids' => array(1,2,3) |
| 12 | * ); |
| 13 | * $report = new \Automattic\WooCommerce\Admin\API\Reports\Variations\Stats\Query( $args ); |
| 14 | * $mydata = $report->get_data(); |
| 15 | */ |
| 16 | |
| 17 | namespace Automattic\WooCommerce\Admin\API\Reports\Variations\Stats; |
| 18 | |
| 19 | defined( 'ABSPATH' ) || exit; |
| 20 | |
| 21 | use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery; |
| 22 | |
| 23 | /** |
| 24 | * API\Reports\Variations\Stats\Query |
| 25 | * |
| 26 | * @deprecated 9.3.0 Variations\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly. |
| 27 | */ |
| 28 | class Query extends ReportsQuery { |
| 29 | |
| 30 | /** |
| 31 | * Valid fields for Products report. |
| 32 | * |
| 33 | * @deprecated 9.3.0 Variations\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly. |
| 34 | * |
| 35 | * @return array |
| 36 | */ |
| 37 | protected function get_default_query_vars() { |
| 38 | wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' ); |
| 39 | |
| 40 | return array(); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Get variations data based on the current query vars. |
| 45 | * |
| 46 | * @deprecated 9.3.0 Variations\Stats\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly. |
| 47 | * |
| 48 | * @return array |
| 49 | */ |
| 50 | public function get_data() { |
| 51 | wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' ); |
| 52 | |
| 53 | $args = apply_filters( 'woocommerce_analytics_variations_stats_query_args', $this->get_query_vars() ); |
| 54 | |
| 55 | $data_store = \WC_Data_Store::load( 'report-variations-stats' ); |
| 56 | $results = $data_store->get_data( $args ); |
| 57 | return apply_filters( 'woocommerce_analytics_variations_stats_select_query', $results, $args ); |
| 58 | } |
| 59 | |
| 60 | } |
| 61 |