Automattic\WooCommerce\Admin\API

ProductVariations::add_wp_query_join()public staticWC 1.0

Join posts meta tables when variation search query is present.

Method of the class: ProductVariations{}

No Hooks.

Return

String.

Usage

$result = ProductVariations::add_wp_query_join( $join, $wp_query );
$join(string) (required)
Join clause used to search posts.
$wp_query(object) (required)
WP_Query object.

ProductVariations::add_wp_query_join() code WC 7.3.0

public static function add_wp_query_join( $join, $wp_query ) {
	global $wpdb;

	$search = $wp_query->get( 'search' );
	if ( $search ) {
		$join .= " LEFT JOIN {$wpdb->postmeta} AS attr_search_meta
					ON {$wpdb->posts}.ID = attr_search_meta.post_id
					AND attr_search_meta.meta_key LIKE 'attribute_%' ";
	}

	if ( wc_product_sku_enabled() && ! strstr( $join, 'wc_product_meta_lookup' ) ) {
		$join .= " LEFT JOIN {$wpdb->wc_product_meta_lookup} wc_product_meta_lookup
					ON $wpdb->posts.ID = wc_product_meta_lookup.product_id ";
	}

	return $join;
}