Home › Forums › WoodMart support forum › On search result page brand filter is not showing all brands
On search result page brand filter is not showing all brands
- This topic has 7 replies, 2 voices, and was last updated 1 year, 5 months ago by
Hung Pham.
-
AuthorPosts
-
June 5, 2024 at 1:44 pm #570790
VokParticipantexample: 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
June 6, 2024 at 7:15 am #570942
Hung PhamParticipantHi 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,
June 6, 2024 at 9:18 am #570963
VokParticipantHere you go.
June 6, 2024 at 10:57 am #571013
Hung PhamParticipantHi Vok,
Thanks for details.
I am regenerating product attributes in WooCommerce > Status > Tools
Regenerate the product attributes lookup tableLet me know the results after process done.
Regards,
June 6, 2024 at 2:21 pm #571095
VokParticipantStill the same problem, not working as it should.
June 7, 2024 at 12:44 pm #571284
Hung PhamParticipantHi 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,
June 7, 2024 at 3:37 pm #571346
VokParticipantNow it works correctly.
Thank you for your time and help.
June 8, 2024 at 8:57 am #571443
Hung PhamParticipantHi 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,
-
AuthorPosts
The topic ‘On search result page brand filter is not showing all brands’ is closed to new replies.
- You must be logged in to create new topics. Login / Register
