You can utilize the “metafields” function from Shopify to hide the product from search without needing to edit your theme's code files.
Step 1: Create Metafield definition
From your shop admin, select Settings and then Metafields
Next, select Products
Create a new Metafield definition with the following properties:
Name: hidden
Namespace: seo
Type: Integer
Validation: min and max should both be 1
Press the save button when you are finished.
Step 2: Add metafield to product you want to hide
Open the detail page of the product you want to hide in your Shopify admin.
Scroll down until you see the metafields section and enter the value "1" for the "hidden" metafield value.
Press save once you are finished.
And now this product will not show up in your store search and search engine like Google. You can try search name of this product in your store and it won’t appear in the search result. How this works is explained by Shopify here.
Step 3: Hide products from collection page
Now that your product is hidden from search, the next place we are going to hide it is from the “All” catalog. By default, all Shopify stores have a “Catalog” page which show all available products (with stock) in your store, this page is usually located inyour-store.myshopify.com/collections/all
.
First, create a collection, and name the title as “All”.
Set the collection to :manual" and select save.
Then next, select all products and add them to the “All” collection, and then select the product you want to hide from the catalog, and click “Remove from collection”, and select the “All” collection.
Now the product which you have removed from the “All” collection will not show up in the Catalog page.
Optional:
If you followed the steps above, you have hidden products from your site search, prevented them from being indexed by search engines, and removed them from the "all" collection. The hidden products can still be accessed by navigating to their URL directly. If you want to make sure customers cannot navigate to the hidden products at all, you will have to make a small change to your product theme.
Locate your Product template.
For most 2.0 themes you will find the product template by looking for the product.json template. Inside this file you will see several sections. One of them will have name similar to main-product. This is the name of the section file that contains your product template.
Add the following snippet at the top of the page and press save.
This snippet will redirect the user back to the home page for any product that has the hidden metafield you created.
{% if product.metafields.seo.hidden.value %}
<script>window.location.href = "/";</script>
{% endif %}