Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › woocommerce products not coming in the result
- This topic has 6 replies, 2 voices, and was last updated 10 years, 5 months ago by
shahrooz.
-
AuthorPosts
-
January 5, 2016 at 10:09 pm #7255
shahrooz
ParticipantHi,
I’ve recently installed Woocommerce on my website and added one product as test. The problem is the search function doesn’t return the product in search result.
If you search for “coolum” in homepage, there should be only one result from Product but nothing to show even “no result” message.
I’ve added Product in “search in custom field” too. Is there anything I’m missing?Please advice,
Thanks,
January 6, 2016 at 9:40 am #7260Ernest Marcinko
KeymasterHi!
It’s going to be a grouping problem. The reason is a bit complicated, but it roots in the fact that wordpress does not allow getting taxonomy term names based only on term IDs without the taxonomy name.
Product categories are actually not the same categories as post categories and the search plugin is not able to get their names in the grouping stage (because the taxonomy is not known at that point). Therefore they are skipped.
I’m actually working on a solution that might get around this problem, but I’m not sure if it’s doable yet. In your case the solution is to use grouping by post type (Advanced Options panel) or not use grouping at all.
January 6, 2016 at 9:44 am #7261shahrooz
ParticipantHi Ernest,
Actually I dont have any grouping in woocommerce. There are only 2 simple products and no result on search. It’s very important for me to have products in my search as the plugin description says its working with woocommerce.
Please take a look at the website to see whats the problem to not showing simple product in result.
Thanks,
January 6, 2016 at 9:47 am #7262Ernest Marcinko
KeymasterI meant search results grouping, not WooCommerce grouping.
On the search instance options panel, Advanced Options -> Grouping you have grouping set to “Group by categories”: http://i.imgur.com/77cF747.png
Tthat is causing the problem. If you change that, the product will appear.
January 6, 2016 at 9:51 am #7263shahrooz
ParticipantOh great! now its showing the products. It would be great if you tell me how to change the order or showing the result. I mean bring product result at first and then the rest..
Thanks,
January 6, 2016 at 10:33 am #7265Ernest Marcinko
KeymasterHi again!
The mixed results ordering is changeable on the General Options -> Ordering panel. Make sure you drag the post_page_cpt item to the top like so: http://i.imgur.com/CR5IG4n.png
However, the product might still appear on the bottom of the post type group list. In that case the only solution is to add one line of code to the plugin to override that ordering.
Open up the wp-content/plugins/ajax-search-pro/includes/search_content.class.php file and go to line 1509, where you should see this:[php]ksort( $pageposts[‘items’] );[/php]
Make a new line right after that one, and put this there:
[php]$pageposts[‘items’] = array_reverse($pageposts[‘items’], true);[/php]
That should do the trick. Sorry about the complicated solution, but the grouping part of the plugin was made a long time ago, and it’s a bit messy at the moment 🙂
January 6, 2016 at 10:43 am #7266shahrooz
ParticipantAwesome support as always.. it’s not complicated at all.. the code worked like a charm.
Thanks Ernest..
-
AuthorPosts
- You must be logged in to reply to this topic.