How to hide products from store search but fix pagination problems

mnearents
Shopify Partner
78 4 48

I am disappointed that this can't be done. I have successfully hidden blog posts as well as certain products from my store's search results. It's pretty easy. All you have to do is add some unless statements in your search.liquid file and it will omit the result.

The problem is the pagination gets messed up. An example is I might get three pages worth of results, but the first page is blank, the second page has 1 item, and the third page has 1 item. Ideally, those two items would simply show up on the first page.

If liquid had the ability to remove items from an array, in theory you could simply remove the offending items from the search.results array before they were counted.

I even downloaded an app (Search Veil) which lets you select products by tag, type, or out of stock and it supposedly hides them from search. But all it's doing is adding a metafield to those products (key: "hidden", namespace: "seo", type: Integer, value: 1). So the problem here is it doesn't work for blog articles, and it doesn't solve the pagination problem.

So if an app can't do it, and I can't do it in my theme code (correct me if I'm wrong), I feel like Shopify should give us the ability to hide blogs and collections from store search (both predictive and non-predictive). 

Reply 1 (1)

mnearents
Shopify Partner
78 4 48

I was able to change the predictive results by editing my theme.js.liquid file. But I don't see the equivalent for regular search. Does anyone know if search results can be modified in JS before they hit the template? Or is this completely handled by Shopify?