Improve updates of onsale/virtual
This commit is contained in:
parent
062d147b59
commit
1e83864667
|
@ -1456,24 +1456,13 @@ function wc_update_product_lookup_tables_column( $column ) {
|
||||||
case 'virtual':
|
case 'virtual':
|
||||||
$column = esc_sql( $column );
|
$column = esc_sql( $column );
|
||||||
|
|
||||||
$wpdb->query(
|
|
||||||
"
|
|
||||||
UPDATE
|
|
||||||
{$wpdb->wc_product_meta_lookup} lookup_table
|
|
||||||
SET
|
|
||||||
lookup_table.`{$column}` = 0
|
|
||||||
"
|
|
||||||
);
|
|
||||||
|
|
||||||
$wpdb->query(
|
$wpdb->query(
|
||||||
"
|
"
|
||||||
UPDATE
|
UPDATE
|
||||||
{$wpdb->wc_product_meta_lookup} lookup_table
|
{$wpdb->wc_product_meta_lookup} lookup_table
|
||||||
LEFT JOIN {$wpdb->postmeta} meta1 ON lookup_table.product_id = meta1.post_id AND meta1.meta_key = '_virtual'
|
LEFT JOIN {$wpdb->postmeta} meta1 ON lookup_table.product_id = meta1.post_id AND meta1.meta_key = '_virtual'
|
||||||
SET
|
SET
|
||||||
lookup_table.`{$column}` = 1
|
lookup_table.`{$column}` = IF ( meta1.meta_value = 'yes', 1, 0 )
|
||||||
WHERE
|
|
||||||
meta1.meta_value = 'yes'
|
|
||||||
"
|
"
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
@ -1481,15 +1470,6 @@ function wc_update_product_lookup_tables_column( $column ) {
|
||||||
$column = esc_sql( $column );
|
$column = esc_sql( $column );
|
||||||
$decimals = absint( wc_get_price_decimals() );
|
$decimals = absint( wc_get_price_decimals() );
|
||||||
|
|
||||||
$wpdb->query(
|
|
||||||
"
|
|
||||||
UPDATE
|
|
||||||
{$wpdb->wc_product_meta_lookup} lookup_table
|
|
||||||
SET
|
|
||||||
lookup_table.`{$column}` = 0
|
|
||||||
"
|
|
||||||
);
|
|
||||||
|
|
||||||
$wpdb->query(
|
$wpdb->query(
|
||||||
$wpdb->prepare(
|
$wpdb->prepare(
|
||||||
"
|
"
|
||||||
|
@ -1498,11 +1478,11 @@ function wc_update_product_lookup_tables_column( $column ) {
|
||||||
LEFT JOIN {$wpdb->postmeta} meta1 ON lookup_table.product_id = meta1.post_id AND meta1.meta_key = '_price'
|
LEFT JOIN {$wpdb->postmeta} meta1 ON lookup_table.product_id = meta1.post_id AND meta1.meta_key = '_price'
|
||||||
LEFT JOIN {$wpdb->postmeta} meta2 ON lookup_table.product_id = meta2.post_id AND meta2.meta_key = '_sale_price'
|
LEFT JOIN {$wpdb->postmeta} meta2 ON lookup_table.product_id = meta2.post_id AND meta2.meta_key = '_sale_price'
|
||||||
SET
|
SET
|
||||||
lookup_table.`{$column}` = 1
|
lookup_table.`{$column}` = IF (
|
||||||
WHERE 1=1
|
CAST( meta1.meta_value AS DECIMAL ) >= 0
|
||||||
AND CAST( meta1.meta_value AS DECIMAL ) >= 0
|
|
||||||
AND CAST( meta2.meta_value AS CHAR ) != ''
|
AND CAST( meta2.meta_value AS CHAR ) != ''
|
||||||
AND CAST( meta1.meta_value AS DECIMAL( 10, %d ) ) = CAST( meta2.meta_value AS DECIMAL( 10, %d ) )
|
AND CAST( meta1.meta_value AS DECIMAL( 10, %d ) ) = CAST( meta2.meta_value AS DECIMAL( 10, %d ) )
|
||||||
|
, 1, 0 )
|
||||||
",
|
",
|
||||||
$decimals,
|
$decimals,
|
||||||
$decimals
|
$decimals
|
||||||
|
|
Loading…
Reference in New Issue