Should this work with the premium version as well?

  • HaikoG
    Participant
    # 2 weeks, 1 day ago

    We’ve just purchased the premium version because we wanted to customize the look and feel of the suggestions box, but after installing the premium version Solr is no longer used for the suggestions.

    If not, what can we do to plug WPSolr in the premium YITH WooCommerce Ajax Search as well?

    wpsolr
    Keymaster
    # 2 weeks, 1 day ago

    Solr is no longer used for the suggestions

    What happened?

    HaikoG
    Participant
    # 2 weeks, 1 day ago

    In the Solr index we’ve added a ‘pricelist_id’, which is used to filter results per usergroup. So, every user has a certain pricelist which dictates which products they see. We’re also indexing the SKU and EAN number of the products. This worked perfectly with WPSolr and the free version of YITH Woocommerce ajax search:

    – Searching a regular product like phone, showed only phones from within the users’ pricelist; Also in the suggestions box.
    – Searching a SKU that’s not in users pricelist, showed ‘No results’, as it should
    – Searching a SKU that is available in the users’ pricelist showed that product, as it should.

    Now we wanted to show the image of the product in the suggestion box. As YITH is used for the suggestion box, I looked in this plugin for the answer, which turned out the free version of YITH can’t do that. So we upgraded the plugin.

    Now the suggestion box is no longer showing the Solr results, but searches the entire product database.

    – Searching a regular product like phone, now shows all product with phone in the title in the suggestion box. But when actually pressing search, we get the filtered Solr results.
    – Searching a SKU that’s not in users pricelist, shows ‘No results’, as it should
    – Searching a SKU that is available in the users’ pricelist now says ‘No results’ when it should show a product. But when I click search, it shows the correct product.

    So this is telling me te suggestionsbox / Yith is no longer using WPSOLR as search engine, but rather the old/regular WP query.

    wpsolr
    Keymaster
    # 2 weeks, 1 day ago

    Indeed, WPSOLR was tested only on the free YITH version.

    HaikoG
    Participant
    # 2 weeks, 1 day ago

    Ok, I’ve tried to find the problem and got a solution

    In

    Replace
    add_action( ‘wp_ajax_yith_ajax_search_products’, [ $this, ‘ajax_search_products’ ], 9 );
    add_action( ‘wp_ajax_nopriv_yith_ajax_search_products’, [ $this, ‘ajax_search_products’ ], 9 );

    with
    if ( ! isset( $_REQUEST[‘wc-ajax’] ) ) {
    add_action( ‘wp_ajax_yith_ajax_search_products’, array( $this, ‘ajax_search_products’ ), 9);
    add_action( ‘wp_ajax_nopriv_yith_ajax_search_products’, array( $this, ‘ajax_search_products’ ), 9 );
    } else {
    add_action( ‘wc_ajax_yith_ajax_search_products’, array( $this, ‘ajax_search_products’ ) , 9);
    }

    and

    $wpsolr_query->query[‘s’] = $query->query[‘s’];
    with
    $wpsolr_query->query[‘s’] = $_REQUEST[‘query’];

    Don’t know if this still works for the free version, but it does for the premium so if anyone runs in to this you can use this

    HaikoG
    Participant
    # 2 weeks, 1 day ago

    Oh, that in class-wpsolr-plugin-yith-woocommerce-ajax-search-free.php

    wpsolr
    Keymaster
    # 2 weeks, 1 day ago

    Thanks for the feedback. I’ll try to integrate that to the next release https://www.wpsolr.com/forums/topic/release-21-9/

    • This reply was modified 2 weeks, 1 day ago by  wpsolr.
    finalwebsites
    Participant
    # 6 days, 5 hours ago

    Hi,

    I have the same problem. We bought the Yith premium to get a better experience.
    The problem is that the whole search mechanism is different from the free version.
    In the free version only some arguments are used for the get_posts() function. For the premium version the use their own taxonomy and meta query arguments. My guess is that it’s the reason why WPSOLR doesn’t work. Any suggestions? My forst idea is to fork the free version and add the extra information to the list of post suggestions (like thumb, categories and price)

    wpsolr
    Keymaster
    # 6 days, 5 hours ago

    You could try the suggestion from HaikoG.

    You can also simply customize the WPSOLR suggestions list. It is a twig template, and can be totally updated (included the data with hooks):

    Image download-suggestions-code-exemple.png of

    finalwebsites
    Participant
    # 5 days ago

    Hi,
    I checked the code form the Yith plugin and noticed they just using the get_posts() functions to get the suggestions for the the ajax search. I’ve built my own search widget using the same function. It looks like that my results are based on WPSOLR (it’s very fast, but my query is searching only inside the title and description. Where can I find some information about custom queries I can perform on the WPsolr search index?
    Thanks

    wpsolr
    Keymaster
    # 4 days, 7 hours ago

    The only official way of proceeding at this moment is to create your own twig suggestions template as described before.

    finalwebsites
    Participant
    # 4 days, 7 hours ago

    Hi,

    this question was more common (sorry for trashing this topic). I will also create queries for posts on different places.
    What kind of query / function or filter can I use?

    wpsolr
    Keymaster
    # 4 days, 7 hours ago

    Can you please create another topic for you new questions?

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.