Home › Forums › Basel support forum › Hidden or Catalog products showing in Search results
Hidden or Catalog products showing in Search results
- This topic has 10 replies, 2 voices, and was last updated 8 years, 2 months ago by Artem Temos.
-
AuthorPosts
-
November 9, 2016 at 9:45 pm #6500
miguel1876ParticipantHi there
I have a specific products in a Category (samples) that I need to exclude from the ajax search results. I have those Catalog Visibility set to “Catalog” only, however they still show in the ajax search results. Also setting them to “Hidden” which I prefer, does work either. They still show in results. I have also tried different bits of code and nothing seems to work, including:
/* Exclude a Category from Search Results */ add_filter( 'pre_get_posts' , 'search_exc_cats' ); function search_exc_cats( $query ) { if( $query->is_admin ) return $query; if( $query->is_search ) { $query->set( 'category__not_in' , array( 224 ) ); // Cat ID } return $query; }
Can you please help?
Thanks
November 9, 2016 at 9:56 pm #6502
miguel1876ParticipantPlease note … I have have this code on there to show 16 results instead of the default :
// Ajax Search Results function basel_header_block_search() { $header_search = basel_get_opt( 'header_search' ); ?> <div class="search-button basel-search-<?php echo esc_attr( $header_search ); ?>"> <a href="#"> <i class="fa fa-search"></i> </a> <div class="basel-search-wrapper"> <div class="basel-search-inner"> <span class="basel-close-search"><?php esc_html_e('close', 'basel'); ?></span> <?php basel_header_block_search_extended( false, true, array('thumbnail' => 1, 'price' => 1, 'count' => 16), false ); ?> </div> </div> </div> <?php }
November 9, 2016 at 10:00 pm #6505
Artem TemosKeymasterHello,
Thank you for contacting us.
As we can understand the problem is only in AJAX search? Samples are not shown when you hit “Enter”?
Regards
November 9, 2016 at 10:04 pm #6508
miguel1876ParticipantHi.
No, that is not the problem.
The problem is that Samples ARE showing in the search results.Example… enter “firm skin” in the search, and you will see this product:
“Sample: Firm Skin Acai Booser Serum 0.10/oz”
This product Catalog visibility is set to Hidden so it should not show in the results.Thanks
November 9, 2016 at 10:07 pm #6511
Artem TemosKeymasterYes, we understand. But when you hit enter and see the search results page, is this product shown there also?
November 9, 2016 at 10:12 pm #6516
miguel1876ParticipantThat is fine. The product page is no problem.
My client just does not want the samples to show in the search results.November 9, 2016 at 10:14 pm #6517
Artem TemosKeymasterOk, we will try to reproduce the problem on our development environment and will back to you soon.
Thank you
November 9, 2016 at 10:15 pm #6519
miguel1876ParticipantThank you very much. 🙂
November 10, 2016 at 6:33 am #6530
Artem TemosKeymasterHello,
This bug will be fixed in our next update. For now you can change the following code in
basel/inc/classes/Search.php
file$query_args = array( 'posts_per_page' => 3, 'post_status' => 'publish', 'post_type' => 'product', 'no_found_rows' => 1, //'order' => $order, 'meta_query' => array() );
with this one
$query_args = array( 'posts_per_page' => 3, 'post_status' => 'publish', 'post_type' => 'product', 'no_found_rows' => 1, //'order' => $order, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('visible', 'search'), 'compare' => 'IN' ) ) );
It should fix your problem.
Kind Regards
November 10, 2016 at 1:43 pm #6541
miguel1876ParticipantHi there
The code worked perfectly.
Thank you so much for your quick help 🙂Cheers
November 10, 2016 at 4:55 pm #6547
Artem TemosKeymasterGreat, you are welcome 🙂
-
AuthorPosts
The topic ‘Hidden or Catalog products showing in Search results’ is closed to new replies.
- You must be logged in to create new topics. Login / Register