Home › Forums › WoodMart support forum › Relevansi plugin + Ajax Search for Everyone
Relevansi plugin + Ajax Search for Everyone
- This topic has 50 replies, 2 voices, and was last updated 2 years, 2 months ago by WASIPLtd_Website.
-
AuthorPosts
-
July 10, 2019 at 11:12 am #132138
FilsterParticipantSorry, 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?
July 10, 2019 at 12:47 pm #132164
newsprinceParticipantI 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.
July 10, 2019 at 1:06 pm #132174
FilsterParticipantI 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
July 10, 2019 at 1:15 pm #132177
newsprinceParticipantIt’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
July 10, 2019 at 1:28 pm #132181
FilsterParticipantNo 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.
August 11, 2019 at 12:22 pm #137467
Jeriss Cloud CenterParticipantDear,
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 coderelevanssi_do_query($results);
after the line 241 in the Woodmart v4.0.22. 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?
ThanksAttachments:
You must be logged in to view attached files.August 11, 2019 at 1:06 pm #137487
newsprinceParticipantYou 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
August 21, 2019 at 2:08 pm #139637
Jeriss Cloud CenterParticipantI’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
August 21, 2019 at 2:09 pm #139641
newsprinceParticipantSend me an email to [email protected]
September 30, 2019 at 6:16 am #147450
topmosthParticipantHi @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!
September 30, 2019 at 7:48 am #147485
newsprinceParticipantLatest 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
September 30, 2019 at 4:10 pm #147616
hallbirdParticipantHi,
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 ?September 30, 2019 at 5:57 pm #147623
newsprinceParticipantYou can index the product category taxonomy if that you mean.
September 30, 2019 at 6:08 pm #147628
hallbirdParticipantHi,
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.September 30, 2019 at 7:03 pm #147631
newsprinceParticipantYes 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.
October 1, 2019 at 6:28 am #147725
hallbirdParticipantHi
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.May 12, 2020 at 10:03 pm #194468
vikdcpParticipantHi, 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.May 13, 2020 at 7:21 am #194541
newsprinceParticipantYes 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
October 25, 2022 at 4:14 pm #416464
WASIPLtd_WebsiteParticipantDoes 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.
October 25, 2022 at 5:40 pm #416494
loraloraParticipantI’m interested too
October 25, 2022 at 6:41 pm #416503
WASIPLtd_WebsiteParticipantI’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
-
AuthorPosts
- You must be logged in to create new topics. Login / Register