On search result page brand filter is not showing all brands
-
example: After searching for part of SKU, search page shows products from 3 brands, but WOODMART WOOCOMMERCE LAYERED NAV only shows two brands.
I tried to Regenerate the product attributes lookup table
and
Woocommerce > Settings > Product tab > Advanced tab and disable Use the product attributes lookup table for catalog filtering checkbox.
But problem still persists.
Best Regards
Hi Vok,
Thanks for reaching to us.
To assist you in the best possible manner, I kindly ask that you please provide me temporary wp-admin info (wp-admin URL, username, password) to the Private Content area, this will allow me to thoroughly investigate and address your concerns more efficiently.
Regards,
Hi Vok,
Thanks for details.
I am regenerating product attributes in WooCommerce > Status > Tools Regenerate the product attributes lookup table
Let me know the results after process done.
Regards,
Still the same problem, not working as it should.
Hi Vok,
Please try to add the code below in the functions.php file in your child theme, let me know if it works correctly.
add_filter( 'woocommerce_get_filtered_term_product_counts_query', function ( $query ) {
if ( empty( $_GET['s'] ) || ! apply_filters( 'woodmart_search_by_sku', woodmart_get_opt( 'search_by_sku' ) ) ) {
return $query;
}
global $wpdb;
$term = woodmart_clean( $_GET['s'] );
$sku_to_parent_id = $wpdb->get_col( $wpdb->prepare( "SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->wc_product_meta_lookup} ml on p.ID = ml.product_id and ml.sku LIKE '%%%s%%' where p.post_parent <> 0 group by p.post_parent", $term ) );
$sku_to_id = $wpdb->get_results( "SELECT product_id FROM {$wpdb->wc_product_meta_lookup} WHERE sku LIKE '%{$term}%';", ARRAY_N );
$sku_to_id_results = array();
if ( is_array( $sku_to_id ) ) {
foreach ( $sku_to_id as $id ) {
$sku_to_id_results[] = $id[0];
}
}
$search_ids = array_merge( $sku_to_id_results, $sku_to_parent_id );
if ( $search_ids ) {
$sql = $wpdb->prepare( "{$wpdb->posts}.ID IN (%s)", implode( ',', $search_ids ) );
$query['where'] = str_replace( "))", ") OR ({$sql}))", $query['where'] );
}
return $query;
});
Regards,
Now it works correctly.
Thank you for your time and help.
Hi Vok,
Glad to hear your issue has been resolved. Keep us in mind for future questions and concerns, we’re always here to help!
If you have a quick minute we always appreciate a 5-star rating on our theme!
https://themeforest.net/item/woodmart-woocommerce-wordpress-theme/reviews/20264492
Your feedback is the motivation to improve our work and services.
Regards,
The topic ‘On search result page brand filter is not showing all brands’ is closed to new replies.