Home Forums WoodMart support forum Relevansi plugin + Ajax Search for Everyone

Relevansi plugin + Ajax Search for Everyone

Viewing 30 posts - 1 through 30 (of 51 total)
  • Author
    Posts
  • #64927

    newsprince
    Participant

    Dear xtemos team.

    I find a way to integrate Relevanssi plugin with your ajax form so that if someone uses a Relevanssi plugin can now search on all product information.

    Relevanssi plugin works just find on its own with your theme BUT on your AJAX search form doesn’t load the corresponding products. Let’s say for example i search “blue jeans” with blue the attribute of product jeans. Your form doesn’t bring any results unless you hit enter then the search is done via Relevanssi plugin.

    But you can integrate relevansi plugin on your ajax form by simply putting a line of code in search.php file.

    So on

    /wp-content/themes/woodmart/inc/classes/search.php

    On line 71

    after

    $results = new WP_Query( apply_filters( ‘woodmart_ajax_get_results’, $query_args ) );

    put that line of code

    relevanssi_do_query( $results );

    Now the AJAX search form brings the results from relevansi plugin so now the search term blue jeans bring the product results.

    If you want please implement it on future updates. It’s an one line of code and the rest of your theme users can now make more advanced search with the free relevansi plugin

    Thank you.

    Please note, for the modification to work Relevanssi plugin must be active.

    #64967

    Artem Temos
    Keymaster

    Hello,

    Thank you very much for the information. We will investigate this in the future.

    Regards

    #65026

    insideweb
    Participant

    Thank you for this feature sir. Seems working fine!

    #65055

    Artem Temos
    Keymaster

    Thank you for the information.

    #65066

    newsprince
    Participant

    Side note for everyone that want to try it.

    To index the variation sku if the product is variable, so that the results will show the corresponding product you must add this snippet too on functions.php or with a snippet plugin.

    https://www.relevanssi.com/knowledge-base/indexing-product-variation-skus-main-product/

    add_filter('relevanssi_content_to_index', 'rlv_index_variation_skus', 10, 2);
    function rlv_index_variation_skus($content, $post) {
    	if ($post->post_type == "product") {
    		$args = array('post_parent' => $post->ID, 'post_type' => 'product_variation', 'posts_per_page' => -1);
    		$variations = get_posts($args);
    		if (!empty($variations)) {
    			foreach ($variations as $variation) {
    				$sku = get_post_meta($variation->ID, '_sku', true);
    				$content .= " $sku";
    			}
    		}
    	}
     
    	return $content;
    }

    Thank you

    #88883

    newsprince
    Participant

    Update:

    Woodmart version 3.2 changed file search.php location and made some modifications.

    Now you have to go to folder:

    /wp-content/themes/woodmart/inc/modules

    edit the search.php file and add after line 233 add:

    relevanssi_do_query( $results );

    That’s it.

    #90970

    Brandboutik
    Participant

    Brilliant Sir! Worked like a charm 🙂

    #101334

    mbiehl
    Participant

    Sorry, I can not php

    How should I exactly add it?

    233 $results = new WP_Query( apply_filters( ‘woodmart_ajax_get_results’, $query_args ) );
    234 $relevanssi_do_query ($ results);

    #101343

    newsprince
    Participant

    Yes like that but you have to install the Relevanssi plugin also

    #101345

    newsprince
    Participant

    Go to folder and open the file

    /wp-content/themes/woodmart/inc/modules/search.php

    #101407

    mbiehl
    Participant

    I have it installed and can not get it to work
    In the attachment times the file
    Thanks for your support

    #101409

    mbiehl
    Participant

    now with attachment

    Attachments:
    You must be logged in to view attached files.
    #101448

    newsprince
    Participant

    You have a space between $ and results.

    relevanssi_do_query($results);

    Copy paste this.

    #101669

    ggeeky
    Participant

    Hi,
    sorry to bother.
    I’ve tried to implement this plugin following your instruction but I can’t get it to work.
    Do you know of any other alternative? Thank you.

    #101737

    newsprince
    Participant

    It is working. Other people tried it too and works. We use it on our shop constantly. Just insert this line of code and then activate the relevanssi plugin. You have to setup the plugin to index the right properties of the products.

    I attach the file.

    Attachments:
    You must be logged in to view attached files.
    #101769

    ggeeky
    Participant

    Thank you. The issue was in the settings of the plugin.
    I very much appreciate your help.
    Have a good one

    #126921

    [email protected]
    Participant

    Awesome topic this thank you very very much @newsprince

    #128377

    [email protected]
    Participant

    Hi since the new update im getting problems with relevansi.

    Notice: Undefined offset: relevanssi/lib/common.php on line 975

    this happends when you use the view more option. anybody here know how to fix this?

    #128378

    newsprince
    Participant

    It’s just a notice. I don’t think it breaks the functionality. Try to contact relevansi plugin developer.

    #128380

    [email protected]
    Participant

    @newsprince

    thx for your quick reply. do you have this problem aswell? i see that this line is no longer present in the search.php file.

    apply_filters( ‘woodmart_ajax_get_results’, $query_args ) );

    #128381

    newsprince
    Participant

    Always use the latest search.php file from woodmart theme and just add the code

    relevanssi_do_query($results);

    after

    $results = new WP_Query( apply_filters( 'woodmart_ajax_search_args', $query_args ) );

    The line is present in latest file, what do you mean it is not?

    #128384

    [email protected]
    Participant

    ok thx!. i was searching the file for ‘woodmart_ajax_get_results’ but could not find it so thats why i made a wrong assumption, sorry for that. still getting the bug but asked relevansi developer what to do. thx agian!

    example
    http://rj.development.bladewp.com/?s=geloofsopbouw&post_type=product

    #128385

    [email protected]
    Participant

    fyi i’m only getting this bug with debug being enabled.

    #128426

    newsprince
    Participant

    It’s a notice. I don’t think affects functionality.

    #132110

    Filster
    Participant

    Hi,
    is this trick still working?

    I have Relevanssi plugin activated and add this line:
    relevanssi_do_query($results);
    after
    $results = new WP_Query( apply_filters( 'woodmart_ajax_search_args', $query_args ) );

    but still got not Relevanssi working on the ajax woodmart search?

    Thank you 🙂

    #132116

    newsprince
    Participant

    Yes it is working. Did you create the relevanssi index with your product attributes etc?

    #132119

    Filster
    Participant

    Hi, thank you for your quick reply newsprince.

    Yes I built the relevanssi index. I already see the users search terms in the “users search” page of relevanssi, but on using I don’t get results.
    Are we ok that with relevanssi I should be able to search post and not only product?

    It isn’t the first time I use Relevanssi, so I don’t figured out what am I missing.

    #132124

    newsprince
    Participant

    It works with the Woodmarts default ajax search form that searches for products. Try that.

    #132125

    Filster
    Participant

    mmm, I thought it was a setting like this in woodmart:
    header builder => see attachment

    So I think that Relevanssi doesn’t get through this parameter? 🙁

    Attachments:
    You must be logged in to view attached files.
    #132131

    newsprince
    Participant

    You want to search products or posts? I don’t get it what you try to accomplish.

Viewing 30 posts - 1 through 30 (of 51 total)