Search results
-
Hi,
I am having trouble with the search results when no results are found it just keeps spinning and takes a while to load. Also when it finally loads it only shows a blank page, it doesn’t show the “no results found” message.
I was also wondering if you can control which results come up first in a search. I would like a particular bolt to come up first when someone does a search for bolts.
Thank you!
The page I need help with: [log in to see the link]
-
Hi,
Can you please share with me some examples of search queries that you are using to find the products?
Regards
Bolts would be an example, I would like to have the products that are called “Hexagon Head Cap Screws” to be the top results for bolts. Thanks for your help.
Well when searching for “Hexagon Head Cap Screws” I see many of such products. When searching for ‘Bolts’ I see a different set of products. But I think the problem here is that “Hexagon Head Cap Screws” products just don’t have the word ‘Bolts’ inside their content fields.
That’s what I thought to but I don’t want to change the name of the product. Is there a way around this?
Also did you find out anything for when no results are found?
About no results – can you please give me some examples of search queries that show such an error?
About ‘Bolts’ search – well you can add this search inside product content or create a new ‘Bolts’ category and attach it to all such products.
Regards
If you type in scew instead of screw you will see what I mean, the page takes forever to load and then just shows “showing results for” with a blank page.
For the other question, I did put them in the bolts category but there are a lot of bolts. Is there a way I can move them to the top of the results?
About loading issue – I tried this search query and for me it almost immediately shows a ‘No results’ message. Maybe this problem appears only when you are logged-in. Please try to log-out and search one more time or use browser incognito mode.
About bolt category – so, as I understand, you want to move to top all products with this category. Is this correct?
Hi,
On the preview it shows no results found but if you hit enter it just sits and spins.
For the other question I want these to show up first when you type “bolts” into the search. https://eeinc.biz/product-category/fasteners/bolts/cap-screws/grade-8-hexagon-head-cap-screw/
Thanks
-
This reply was modified 3 years, 1 month ago by
cheyenne711.
In fact I see a page when there are no results. For some reason it’s just loads too long.
About “bolts” search – what can be done here is to add more relevance for products with this category so they must appear higher in the search results list.
So please try to use following code snippet:
add_filter( 'aws_search_query_array', 'my_aws_search_query_array' ); function my_aws_search_query_array( $query ) { $products = get_posts( array( 'post_type' => 'product', 'numberposts' => -1, 'post_status' => 'publish', 'fields' => 'ids', 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => 'bolts', /*category slug*/ 'operator' => 'IN', ) ), )); if ( ! empty( $products ) ) { $featured_st = implode(',', $products); $relevance = "( case when ID IN ( " . $featured_st . " ) then 800 else 0 end ) + "; $query['relevance'] = preg_replace( '/\(SUM\([\s\S]*?\([\s\S]*?case[\s\S]*?end[\s\S]*?\)[\s\S]*?\+/i', '$0' . $relevance, $query['relevance'] ); } return $query; }You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.
Also, after adding this code you will need to go to the plugin settings page and click the ‘Clear cache’ button.
Regards
Thanks, when the page finally loads it doesn’t show the”no results found text”. It just shows a blank page beneath “showing results for…”. Do you have a fix for this? Maybe a redirect to another page?
So it is, as I see, an issue with your current theme template for the search results page when there are no search results. This template just doesn’t show any message. For example page https://eeinc.biz/?s=scew&post_type=product show default search results ( not the plugin search results ) but still we see the same issue here.
Maybe you can ask the theme author about this issue? Usually template for product search results must be specified inside the archive-product.php file of your theme. So you also can edit it to add that ‘No results’ message.
When I disable the AWS plugin, the message “no results found” appears fine.
Also thanks for the other code but that wasn’t what I needed. I need these bolts (cap screws) https://eeinc.biz/product-category/fasteners/bolts/grade-8-hexagon-head-cap-screw/ to appear first when someone puts in the keyword bolts. Do you have any suggestions?
Nevermind I was able to sort based on product order. If you could help me with the no results found page though I would greatly appreciate it.
So using the code below made the bolts appear first but then it affects all of the other products so now for example “wire nuts” appear after wire and stripping tools when putting in the search term “wire nuts”. Is it possible to have the code only take affect when searching within the “bolts category” or to prioritize products of my choosing?
Also is it possible to have the search match more than one word i.e if putting in the search for “wire nuts” it would only include products that include both words?
add_filter( 'aws_search_results_products', 'my_aws_search_results_products' ); function my_aws_search_results_products( $products ) { usort($products, function ($item1, $item2) { $product1 = wc_get_product( $item1['id'] ); $product2 = wc_get_product( $item2['id'] ); if ( $product1->is_featured() ) { return -1; } if ( $product2->is_featured() ) { return 1; } return 0; }); return $products; }Thanks in advance.
-
This reply was modified 3 years, 1 month ago by
The topic ‘Search results’ is closed to new replies.