Add missing JOIN parts from tax meta and meta queries.
The SQL query used to calculate the product counts using the product attributes lookup table for the attribute filtering widget was missing the JOIN parts coming from the tax meta and meta queries. The WHERE parts however were being used, so the enitre query could fail if there was a tax or meta query in place.
This commit is contained in:
parent
70431ead2b
commit
4b4f9a2b5d
|
@ -196,7 +196,9 @@ class Filterer {
|
|||
|
||||
$query['select'] = 'SELECT COUNT(DISTINCT product_or_parent_id) as term_count, term_id as term_count_id';
|
||||
$query['from'] = "FROM {$this->lookup_table_name}";
|
||||
$query['join'] = "INNER JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$this->lookup_table_name}.product_or_parent_id";
|
||||
$query['join'] = "
|
||||
{$tax_query_sql['join']} {$meta_query_sql['join']}
|
||||
INNER JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$this->lookup_table_name}.product_or_parent_id";
|
||||
|
||||
$term_ids_sql = $this->get_term_ids_sql( $term_ids );
|
||||
$query['where'] = "
|
||||
|
|
Loading…
Reference in New Issue