woocommerce products not coming in the result

Home Forums Product Support Forums Ajax Search Pro for WordPress Support woocommerce products not coming in the result

This topic contains 6 replies, has 2 voices, and was last updated by shahrooz shahrooz 8 years, 3 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #7255
    shahrooz
    shahrooz
    Participant

    Hi,

    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,

    #7260
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #7261
    shahrooz
    shahrooz
    Participant

    Hi 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,

    #7262
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    I meant search results grouping, not WooCommerce grouping.

    On the search instance options panel, Advanced Options -> Grouping you have grouping set to “Group by categories”: https://i.imgur.com/77cF747.png

    Tthat is causing the problem. If you change that, the product will appear.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #7263
    shahrooz
    shahrooz
    Participant

    Oh 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,

    #7265
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi 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: https://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:

    ksort( $pageposts['items'] );

    Make a new line right after that one, and put this there:

    $pageposts['items'] = array_reverse($pageposts['items'], true);

    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 🙂

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #7266
    shahrooz
    shahrooz
    Participant

    Awesome support as always.. it’s not complicated at all.. the code worked like a charm.

    Thanks Ernest..

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.