• When I do a product search, I no longer have results.
    I disabled all plugins and then it worked. Then I enabled Relevanssi and it stopped working. Can you please check what is going on?

    The page I need help with: [log in to see the link]

Viewing 10 replies - 16 through 25 (of 25 total)
  • Plugin Author Mikko Saari

    (@msaari)

    I’ve found a fix to the problem, and it’s surprisingly simple. Just add this to your theme functions.php:

    remove_filter( 'posts_request', 'relevanssi_prevent_default_request' );

    I’m still trying to figure out what exactly has happened, and how to best implement this change in Relevanssi, but the next version of Relevanssi will include this fix.

    If this doesn’t fix the problem for someone, please let me know.

    Plugin Author Mikko Saari

    (@msaari)

    Further detail, in case someone can offer some suggestions:

    The key here is wc_get_loop_prop( 'total' ) in the archive-product.php template from WooCommerce. With Relevanssi enabled and relevanssi_prevent_default_request active, this returns 0, because Relevanssi prevents the default request and thus no posts are found, even though Relevanssi has found posts. With relevanssi_prevent_default_request disabled, wc_get_loop_prop( 'total' ) returns a non-zero value and WooCommerce is happy displaying the Relevanssi results.

    I’ve confirmed this has changed between WooCommerce versions 4.3.3 and 4.4.0. For some reason wc_get_loop_prop( 'total' ) doesn’t return 0 with WC 4.3.3. Still digging into this…

    Thread Starter darkallman

    (@darkallman)

    Did you test with WC 4.4.1?

    Plugin Author Mikko Saari

    (@msaari)

    Yes, I’m working with 4.4.1. No difference between 4.4.0 and 4.4.1.

    Seems to me the key function here is unchanged between 4.3 and 4.4, so this is all quite bizarre, I don’t know why the two versions behave in different ways.

    Thread Starter darkallman

    (@darkallman)

    Maybe open a github issue with WooCommerce?

    Plugin Author Mikko Saari

    (@msaari)

    Found it! The reason for this is the new adjust_posts_count() function, introduced in WooCommerce 4.4.0. This function causes WooCommerce to set up the post loop before Relevanssi has done the search, causing all these problems. In previous versions, the post loop was set up only after Relevanssi had done it’s job, which made everything work smooth.

    Now, with the fix above, the search still works, but there are some problems. At least Storefront displays the wrong number of results, because it uses the number generated by adjust_posts_count() before Relevanssi. I’m not sure how to fix this so yes, a GitHub issue with WooCommerce is the way to go.

    Thread Starter darkallman

    (@darkallman)

    Excellent investigation Mikko! These kind of changes are always tough. Hope you will find a solution soon.

    Plugin Author Mikko Saari

    (@msaari)

    Writing the issue was the key, it lead me to a better solution. Adding this to the theme functions.php should also fix the problem:

    add_action( 'woocommerce_before_shop_loop', 'wc_reset_loop' );

    This is a better solution than

    remove_filter( 'posts_request', 'relevanssi_prevent_default_request' );

    because with this better solution, the found post counts on the results pages should be correct.

    I still posted the issue, I suppose it’s good for the WooCommerce folks to know about the side effects of the changes in the plugin: https://github.com/woocommerce/woocommerce/issues/27420

    Thanks to all who brought this issue to my attention.

    Thread Starter darkallman

    (@darkallman)

    I gave your github issue a thumbs up!

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @msaari I have archived your reply and flagged your account for moderation.

    While I know you have the best of intentions, it’s forum policy that you not ask users for admin or server access. Users on the forums aren’t your customers, they’re your open source collaborators, and requesting that kind of access can put you and them at high risk.

    If they are paying customers (such as people who bought a premium service/product from you) then by all means, direct them to your official customer support system. But in all other cases, you need to help them here on the forums.

    Thankfully are other ways to get information you need:

    You get the idea.

    We know volunteer support is not easy, and this guideline can feel needlessly restrictive. It’s actually there to protect you as much as end users. Should their site be hacked or have any issues after you accessed it, you could be held legally liable for damages. In addition, it’s difficult for end users to know the difference between helpful developers and people with malicious intentions. Because of that, we rely on plugin developers and long-standing volunteers (like you) to help us and uphold this particular guideline.

    When you help users here and in public, you also help the next person with the same problem. They’ll be able to read the debugging and solution and educate themselves. That’s how we get the next generation of developers.

    I am now closing this topic as it became a pile on topic and I have archived the replies.

    If anyone needs support then per the forum guidelines please start your own topic.

    https://www.ads-software.com/support/forum-user-guide/faq/#i-have-the-same-problem-can-i-just-reply-to-someone-elses-post-with-me-too

    You can do so here.

    https://www.ads-software.com/support/plugin/relevanssi/#new-post

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Product Search no longer working’ is closed to new replies.