Automattic\WooCommerce\Admin\API\Reports\Variations
DataStore::add_from_sql_params
Fills FROM clause of SQL request based on user supplied parameters.
Method of the class: DataStore{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->add_from_sql_params( $query_args, $arg_name );
- $query_args(array) (required)
- Parameters supplied by the user.
- $arg_name(string) (required)
- Target of the JOIN sql param.
DataStore::add_from_sql_params() DataStore::add from sql params code WC 11.2.2
protected function add_from_sql_params( $query_args, $arg_name ) {
global $wpdb;
if ( 'sku' !== $query_args['orderby'] ) {
return;
}
$table_name = self::get_db_table_name();
$join = "LEFT JOIN {$wpdb->postmeta} AS postmeta ON {$table_name}.variation_id = postmeta.post_id AND postmeta.meta_key = '_sku'";
if ( 'inner' === $arg_name ) {
$this->subquery->add_sql_clause( 'join', $join );
} else {
$this->add_sql_clause( 'join', $join );
}
}