When facets leave only one product, it gets rendered via single-product.php

  • wpsolr
    Keymaster
    4 years, 6 months ago #14751

    You can try to track when the template is switched.

    leomoon
    Participant
    4 years, 6 months ago #14754

    In template-loader.php, below line 47, the conditional is_singular() returns true and naturally the single product template is choosen for rendering.
    Now when and why $GLOBALS[‘WP_Query’]->is_singular is switched to true, that I could find.

    leomoon
    Participant
    4 years, 6 months ago #14755

    I could not find I meant to say.

    wpsolr
    Keymaster
    4 years, 6 months ago #14756

    Can you debug in wp-content/plugins/wpsolr-pro/wpsolr/core/classes/services/class-wpsolr-service-container.php WPSOLR_Service_Container::get_is_replace_by_wpsolr_query() ?

    Comment out the whole function content to replace it with “return true;” and see what happens.

    leomoon
    Participant
    4 years, 6 months ago #14757

    What happens is that instead of getting related products, I get all the products from a set, as if no filters are selected. If I select any of the filters with more than one product, it works fine. The problem is still when its filtered down to just one product.

    mcl7
    Participant
    3 years, 5 months ago #22838

    I had this problem but I forgot that I had added some code previously that redirects the user to the product page if there was only one product. Make sure something like that isn’t in place. How does it behave with WPsolr off when you click on a category with one item in it?

    leomoon
    Participant
    3 years, 5 months ago #22846

    This was the solution in my case…

    add_filter( ‘woocommerce_redirect_single_search_result’, ‘__return_false’ );

    But still, if someone wants a product page to display in case of a single result, this plugin should handle that properly as well. If using faucets however, you don’t want that to happen.

Viewing 7 posts - 16 through 22 (of 22 total)

You must be logged in to reply to this topic.