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 has 4 replies, 2 voices, and was last updated 5 years ago by
niumalta96.
-
AuthorPosts
-
May 6, 2021 at 12:24 pm #33095
niumalta96
ParticipantSFTP Port: 29841
We are using the Ajax Pro Plugin search page.
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 5 years ago by
niumalta96.
-
This topic was modified 5 years ago by
niumalta96.
May 6, 2021 at 12:37 pm #33100Ernest Marcinko
KeymasterHi,
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
May 6, 2021 at 5:50 pm #33105niumalta96
ParticipantYes 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 5 years ago by
niumalta96.
May 7, 2021 at 8:15 am #33110Ernest Marcinko
KeymasterIn 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.
May 7, 2021 at 9:11 am #33115niumalta96
ParticipantOk perfect. Thank you, will let you know in case we have any other issues.
-
This topic was modified 5 years ago by
-
AuthorPosts
- The topic ‘Ordering/Grouping Out of Stock Items to the bottom of the search results’ is closed to new replies.