Hi @3sonsdevelopment,
That is very helpful information! I admit it has been a long time since I looked at this, and I couldn’t recall which search block the site uses, so I checked out our settings and did a little testing.
I can’t speak for @kateeba, but I am using the regular WP Search Block for search in order to have only one search widget that meets all the site’s needs. We use Relevanssi, which allows search by SKU in WooCommerce, a feature we need, instead of the WooCommerce Product Search Block, which doesn’t have that functionality as far as I know. Using Relevanssi, our Search Block will also search regular posts for content related to the products sold on the site, but as configured, it was showing hidden products.
I looked at Relevanssi’s settings, and you are correct: Relevanssi does have a setting called, “Respect exclude_from_search for custom post types” in Settings > Relevanssi > Search. I enabled it and it now prevents hidden products from appearing in search results. Relevanssi does show a warning when exclude from search is enabled that says, “You probably should uncheck this option, because you’ve set Relevanssi to index the following non-public post types: product_variation.” In my testing, I can still pull up product variations using the SKU, so I think we’re okay.
Thanks again.