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

Relevansi plugin + Ajax Search for Everyone

Viewing 21 posts - 31 through 51 (of 51 total)
  • Author
    Posts
  • #132138

    Filster
    Participant

    Sorry, I was not clear enough.

    I want to (and thought) that I can search both (posts and products) due to Relevanssi.

    So when I was testing, I was trying to search posts results and this is why I thought Relevanssi didn’t work. But in fact, it works (with products only)

    There’s no simple way to search products AND post?

    #132164

    newsprince
    Participant

    I have a solution but you will lost the ability to choose what post type every search form will bring. Basically every search form by default will search for products and posts and portfolio items. If you are ok with this tell me to write the solution.

    #132174

    Filster
    Participant

    I only have two customs header with the same search form, well it wouldn’t be an issue if I can’t choose anymore between types (post, portfolio, products)
    So yes, I’m really grateful if you can write me a code snippet to overpass this woodmart settings/default behavior!

    Thank you very much

    #132177

    newsprince
    Participant

    It’s not a snippet. You have to manually delete and add some code, but beware. In every theme update you have to apply the same settings.

    So 1st go to:

    /wp-content/themes/woodmart/inc/builder/elements/Search.php

    and delete the following code from line 119 to 140

    'post_type' => array(
    						'id' => 'post_type',
    						'title' => esc_html__( 'Post type', 'woodmart' ),
    						'type' => 'selector',
    						'tab' => esc_html__( 'General', 'woodmart' ),
    						'value' => 'product',
    						'options' => array(
    							'product' => array(
    								'value' => 'product',
    								'label' => esc_html__( 'Product', 'woodmart' ),
    							),
    							'post' => array(
    								'value' => 'post',
    								'label' => esc_html__( 'Post', 'woodmart' ),
    							),
    							'portfolio' => array(
    								'value' => 'portfolio',
    								'label' => esc_html__( 'Portfolio', 'woodmart' ),
    							),
    						),
    						'description' => esc_html__( 'You can set up the search for posts, projects or for products (woocommerce).', 'woodmart' ),
    					),

    2nd go to:

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

    In line 194 replace the

    $post_type = 'product';

    with this code

    $post_type = array('post', 'product', 'portfolio');

    After that go to your header builder. Open your header go to the search widget click edit save and lastly save header.

    Clear cache and go make a search.

    Now you should see products posts portfolio items as long as you have indexed them with relevanssi

    #132181

    Filster
    Participant

    No problem, I will save this two files and re-upload them on woodmart updates. (if they don’t make change in this files I guess)

    Thank you so soo much!!! It worked at the first try by following your process.

    So now I get my ajax relevanssi deeper search working, also I can search posts and products.
    Woodmart + your custom code is absolutely gorgeous.

    Thanks again, I think this thread will be usefull for others users.

    #137467

    Jeriss Cloud Center
    Participant

    Dear,

    I am not able to make the Relevanssi plugin work with Woodmart. Can you please review the steps below and make sure that I got it all right?

    1. I’ve created a staging site where I’ve modified the file search.php in the location /wp-content/themes/woodmart/inc/modules where I’ve added the code relevanssi_do_query($results); after the line 241 in the Woodmart v4.0.2

    2. I’ve added in functions.php the code

    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;
    }

    3. I’ve checked that the search feature in the Woodmart header builder is set to “AJAX Search Results”

    However, I’m still not getting the results from Relevanssi. What did I do wrong?
    Thanks

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

    newsprince
    Participant

    @gevcen

    You have to also create the Relevanssi index.

    Go to Settings > Relevanssi > Indexing

    Choose

    Post types > Checkbox > product, product_variation

    Taxonomies > product_cat, product_tag + what other taxonomy you want to search

    Custom Fields > Some > _sku, _sale_price

    Save options

    and then Build Index.

    It is working still in 4.0.2 everything is good

    #139637

    Jeriss Cloud Center
    Participant

    @newsprince

    I’ve done exactly as you said, but it does not work. I don’t understand what’s wrong…

    Do you mind I grant you access to my staging site and you tell me what I’ve done wrong?

    Thanks

    #139641

    newsprince
    Participant

    @gevcen

    Send me an email to [email protected]

    #147450

    topmosth
    Participant

    Hi @newsprince it seems that search.php is not available/visible on /wp-content/themes/woodmart/inc/classes/ folder. Do you have any way on how to insert this line of code
    relevanssi_do_query( $results );

    Thank you!

    #147485

    newsprince
    Participant

    @topmosth

    Latest version of Woodmart 4.1 has an option to turn on relevanssi search now without any custom code.

    Go to Theme Settings > Shop > Use Relevanssi for AJAX search > ON

    #147616

    hallbird
    Participant

    Hi,
    thanks for the hard work,
    the search dose not seems respect the product category. it load whatever match the search string.
    is there a workaround ?

    #147623

    newsprince
    Participant

    @hallbird

    You can index the product category taxonomy if that you mean.

    #147628

    hallbird
    Participant

    Hi,
    I did index the category and tags for product,
    In homepage when I select a certain category the number of return data should be limited to that category actually it’s not, it pull all the data.

    #147631

    newsprince
    Participant

    @hallbird

    Yes sorry the relevanssi does not respect the chosen category from woodmart ajax search like it does without the relevanssi enabled.

    I don’t have a solution for this. Maybe Artem Temos can help.

    #147725

    hallbird
    Participant

    Hi
    Thanks for the update,
    That’s sad such amazing functionality cannot be controlled by category,
    Then I have to remove the category from the search bar since it will be misleading.
    I hope a fix can be provided.

    #194468

    vikdcp
    Participant

    Hi, i’d like to make work search for tags, is it possible?
    i want search tool, find by categories, but also by tags, i hope you can help me, thanks.

    #194541

    newsprince
    Participant

    @vikdcp

    Yes it is possible. Go to relevanssi plugin settings and check to index the tags or what ever you like. Rebuild the index and then the search will bring products from tags search

    #416464

    WASIPLtd_Website
    Participant

    Does anyone know if this still works?

    It’s truly a pain to not be able to search product tags on the theme…

    Thanks in advance.

    #416494

    loralora
    Participant

    I’m interested too

    #416503

    WASIPLtd_Website
    Participant

    @Loralora

    I’ve figured it out.

    Go to Theme Settings > Shop > Use Relevanssi for AJAX search > ON

    You must index your products after installing the plugin, then turn on the setting for it to work

Viewing 21 posts - 31 through 51 (of 51 total)