Ordering/Grouping Out of Stock Items to the bottom of the search results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Ordering/Grouping Out of Stock Items to the bottom of the search results

This topic contains 4 replies, has 2 voices, and was last updated by niumalta96 niumalta96 1 year, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33095
    niumalta96
    niumalta96
    Participant

    SFTP Port: 29841

    We are using the Ajax Pro Plugin search page.

    Search for Iphone: https://xxxx.com/?post_type=product&s=iphone&asp_active=1&p_asid=1&p_asp_data=1&current_page_id=909&woo_currency=EUR&qtranslate_lang=0&filters_changed=0&filters_initial=1&asp_gen%5B%5D=title&asp_gen%5B%5D=content&asp_gen%5B%5D=excerpt&customset%5B%5D=product_variation&customset%5B%5D=product

    In the results we are currently seeing all the products related to the keyword ‘iphone’. Our clients are happy with the logic and functionality provided by your plugin, however we have one last thing that we would like to do. We would like to put the ‘Out of stock’ items to the bottom of the search results. Is there a way this can be done when executing the sql query? We do not want to loop through the results and order them after the sql query has been executed through a foreach in php since this site has a lot of products and if the query returns a lot of results we might end up facing memory issues.

    From the rest of the ordering logic attached we do not want to change anything, when it comes to primary and secondary logic, since it would result in changing the logic of the search on the header.

    • This topic was modified 1 year, 10 months ago by niumalta96 niumalta96.
    • This topic was modified 1 year, 10 months ago by niumalta96 niumalta96.
    Attachments:
    You must be logged in to view attached files.
    #33100
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Actually, I think it is possible without any custom coding. Try using the “stock_status” custom field for the primary ordering, and relevance as secondary: https://i.imgur.com/5ibnSxd.png

    Best,
    Ernest Marcinko

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


    #33105
    niumalta96
    niumalta96
    Participant

    Yes we already tried that but unfortunately we would loose our current secondary logic which is by pricing DESC. If we had 3 conditional logic for ordering we would be able to do so however with 2 we would change the current product ordering.

    We do not mind hooking to any of the plugin’s filters if there is no way to do it through plugin settings.

    • This reply was modified 1 year, 10 months ago by niumalta96 niumalta96.
    #33110
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    In that case, you can still try the group priorities feature. Try creating a rul group and set the priority to 101. Then the rule should be on the “_stock_status” custom field: https://i.imgur.com/Qo7Tqmb.png
    After saving the groups, the items in stock should be prioritized, and the primary/secondary ordering applied by group basis.

    To make direct changes to the final query, you can use these hooks.

    Best,
    Ernest Marcinko

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


    #33115
    niumalta96
    niumalta96
    Participant

    Ok perfect. Thank you, will let you know in case we have any other issues.

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

You must be logged in to reply to this topic.