msaari / relevanssi

Relevanssi, a WordPress plugin to improve the search
GNU General Public License v3.0
49 stars 21 forks source link

YITH Badge Management problem with Relevanssi active #48

Closed CarlosLongarela closed 2 years ago

CarlosLongarela commented 2 years ago

With Relevanssi enabled, YITH Badge Management plugin do not return badge results. Yith support team advertise me that with Relevanssi disabled all works fine and that I should to contact you to resolve the problem (I'm uncertain if the problem is from YITH plugin or Relevanssi).

msaari commented 2 years ago

I tried using YITH Badge Management with Relevanssi and noticed no problems. I could create badges and search for them in the editor and on the product edit pages as expected.

Could you please explain how to reproduce this issue?

CarlosLongarela commented 2 years ago

The problem is with badge selection on categories. Check this quick video wit Relevanssi enabled and disabled https://video.tabernawp.com/conversations/fdc340de-b716-5e74-aa8c-0e75377f147c

msaari commented 2 years ago

Ah, that's a Premium feature. But you showed me the AJAX query parameters on the video; that was very helpful. Try adding this to your site:

add_filter( 'relevanssi_prevent_default_request', 'rlv_yith_badge_management', 10, 2 );
add_filter( 'relevanssi_search_ok', 'rlv_yith_badge_management', 10, 2 );
function rlv_yith_badge_management( $do_stuff, $query ) {
    if ( 'yith-wcbm-badge' === $query->query_vars['post_type'] ) {
        $do_stuff = false;
    }
    return $do_stuff;
}

This should fix at least the badge search. If the category search still fails, please show me the AJAX query variables for that search as well.

CarlosLongarela commented 2 years ago

I test it and works like a charm, thanks a lot @msaari quick and excellent solution.

All the best, Carlos Longarela.