Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Exlcude variations from search results IF the variable/parent product is shown?
- This topic has 8 replies, 2 voices, and was last updated 8 years, 6 months ago by
Ernest Marcinko.
-
AuthorPosts
-
November 9, 2017 at 5:54 pm #15456
iscsales
ParticipantWe would like to exlcude product variations from search results IF the variable/parent product is shown in the results. Does this option already exist somewhere in the admin? I’ve looked through each panel and have not found it. The following example shows a variable product and all matching variations also listed:
Thanks!
November 10, 2017 at 9:58 am #15459Ernest Marcinko
KeymasterHi,
Unfortunately there is no option for that, as it cannot be filtered during the database query, only via post processing.
However I recall that about a year ago someone asked a similar questions, and I have found a custom code that was working for him. I searched and found the snippet. Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
This might do the trick, although it’s not the best solution, but the only I can think of.
November 10, 2017 at 3:32 pm #15462iscsales
ParticipantWorks like a charm – thanks!
November 13, 2017 at 7:28 am #15470Ernest Marcinko
KeymasterYou cannot access this content.
November 13, 2017 at 7:36 pm #15493iscsales
ParticipantErnest,
I noticed something unusual related to this change. While the results are being removed exactly as requested, it looks like the number of results and the pages of results are both thrown off. For example, this page shows 50 results with 11 appearing on page one, then there is a 404 on page 2:
Is there a way that this code snippet can also be used to correct the number of results and pagination?
November 14, 2017 at 2:06 pm #15510Ernest Marcinko
KeymasterHi,
Yes, it is kind of the problem with tempering the results after the post-process. I will look into this on my local environment. Maybe I can make a modification to the main search query file to somehow detect the changes in results count.
Will get back to you a bit later.
November 14, 2017 at 2:49 pm #15511Ernest Marcinko
KeymasterHi,
I think I may have found a possible solution, at least it appears to be working on my local environment. You will have to replace one file in the search directory. If it works correctly, I will include this change in the upcoming release as well.
1. Before you start, make sure to have a site back-up, just in case.
2. Open up the wp-content\plugins\ajax-search-pro\includes\classes\search\class-asp-query.php file on your server
3. Replace it’s contents with this: asp-query.php
4. Save the file.Do a test search, and hopefully the counter should be showing the correct amount now.
November 16, 2017 at 6:05 pm #15554iscsales
ParticipantErnest,
That worked perfectly. Thanks very much!
Regards,
Mark PraschanNovember 17, 2017 at 8:05 am #15565Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.