is_existing_sku use lookup
This commit is contained in:
parent
e6c60dd6c2
commit
f6d9e7796f
|
@ -949,13 +949,15 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
// phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery
|
// phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery
|
||||||
return $wpdb->get_var(
|
return $wpdb->get_var(
|
||||||
$wpdb->prepare(
|
$wpdb->prepare(
|
||||||
"SELECT $wpdb->posts.ID
|
"
|
||||||
FROM $wpdb->posts
|
SELECT posts.ID
|
||||||
LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )
|
FROM {$wpdb->posts} as posts
|
||||||
WHERE $wpdb->posts.post_type IN ( 'product', 'product_variation' )
|
INNER JOIN {$wpdb->wc_product_meta_lookup} AS lookup ON posts.ID = lookup.product_id
|
||||||
AND $wpdb->posts.post_status != 'trash'
|
WHERE
|
||||||
AND $wpdb->postmeta.meta_key = '_sku' AND $wpdb->postmeta.meta_value = %s
|
posts.post_type IN ( 'product', 'product_variation' )
|
||||||
AND $wpdb->postmeta.post_id <> %d
|
AND posts.post_status != 'trash'
|
||||||
|
AND lookup.sku = %s
|
||||||
|
AND posts.ID <> %d
|
||||||
LIMIT 1",
|
LIMIT 1",
|
||||||
wp_slash( $sku ),
|
wp_slash( $sku ),
|
||||||
$product_id
|
$product_id
|
||||||
|
|
Loading…
Reference in New Issue