I have just rebuilt a Shopify store for a friend. It has the commerce side of things and it has blog articles as well. What I'm trying to do is to get the search function to return results from the blog as well as the products. For example... one of the products is a "2FA Boost" guitar effects pedal. Using the search definitely returns both versions of the product but not the blog article on them. As there is so much good info in the years of blog articles, it's almost imperative to have this functionality. If you're a potential customer of this store, you would want to be able to search through the 500 (or more) blog entries too.
My friend, the store owner, is certain the previous theme supported this. I have compared the search code (search.liquid, search-form.liquid, search-bar.liquid) with the previous theme code. I have looked for a search app that might help too, but nothing seems to offer this function, well, of those I have looked at.
I have also engaged the theme author support but they have been slow to respond (which I can understand) and not entirely on the same page as me with this question. I'm getting a little frustrated and maybe a little desperate to make this all work properly.
So this is my question: can I make the search function on a Shopify store also return results from the blog?
FWIW, the site is here: https://tymguitars.com.au/
Thanks in advance to all who might weigh in on this one. Your advice and suggestions are VERY welcome!
Aibek is here from Speedimize.io
https://shopify.dev/tutorials/use-advanced-query-parameters-in-shopify-online-store-search#query-par... - to get the articles, try changing the url as in the tutorial.
For example: /search?q=2FA+Boost&type=article
The above example will search among the articles.
If the type is not specified, it will search everywhere.
By default, there is a search for products, that is, the type specified is product.
We have studied how the search works in your case. When we tested the search, when searching for a product, an ajax request is not sent. After checking, we found out that when the page loads, another ajax request is sent, which gets all the collections/all products?view=ajaxsearch
It may have been done that the search seemed fast when typing on the search input data.
Most likely, this is why you do not display the articles.
The function is called ajaxProductItems. Located in plugin.js 892 line http://joxi.ru/8AnGJZ4tzeXzgr
And then when searching this function is triggered ajaxSearch 923 line http://joxi.ru/L21vKM7uRQnRjA. Also located in plugin.js. But the Ajax request is not sent, since all the products were received in advance. The products are just being drawn. Now I hope it is clear why the articles are not shown.
Or you should edit ajaxProductItems so that you get more than just products. Or rewrite the ajaxSearch function to already send an ajax request and at the same time receive not only products. In that case. you can get rid of ajaxProductItems.
If you have any questions, please contact us and we will try to help you.
Hi there Aibek @Speedimize
Thank you so much for your reply. I have followed your information as best I can - and I am feeling out of my depth now - and things are no better for now. Both the search.liquid and search-form.liquid contain the following lines of code:
<input type="hidden" name="type" value="product" />
<input type="hidden" name="type" value="article" />
<input type="hidden" name="type" value="page" />
...which I thought would be correct and return the required results, but as you know already, it still doesn't function as expected. I assume this is related to the ajaxsearch which is not obvious to me.
It would seem to me, as a very unqualified script editor, that editing ajaxProductItems does make the best sense, but after looking at it, I am not sure what is the best thing to do.
Any further advice is welcomed. If this proves to be beyond my ability, do you offer this editing service? My first call for assistance was answered by some very expensive support companies that we simply can't afford to engage.
Thank you again for your help. It is VERY MUCH appreciated!
Thanks for getting back to me.
You will not receive the articles, because the Ajax request goes to this url https://tymguitars.com.au/collections/all?view=ajaxsearch. In any case, no matter what data you send to this url, the answer will always be products.
We would do this. This request would be deleted, so that instead of writing a new Ajax request, which will be triggered only when the search is going on. Then you can already pass the type of requested resources.
If you do not succeed, we can discuss the details in private messages or you can send us email here: firstname.lastname@example.org and we will be glad to help you.