My situation: we have a Shopify store, we also have a search engine implemented and hosted on AWS. We need to use that search engine instead of the default /search on our Shopify store.
Ideally, when users try to search something, their query (and potentially some other stuff like attribute selectors/checkboxes on the front end) will be passed to our search engine. Then after the result is back, they will be rendered at the front end.
My Question: how should I do this?
Option 1: modify the theme code, inject some javascript to call the search engine (Possible, but messy)
Option 2: write an app, wrap my search engine within the app, and somehow plug it in the store (I don't know how to do this)
Option 3: similar to Option 1, but write an app, use the app to inject some code to the theme, and somehow handle the work. (I don't know how to do this either)
I found a similar post here: Write custom search app in shopify but the answers below were more about filtering/modifying search result returned by the default shopify engine, I want to instead use my own search engine.
Essentially my problem was to redirect user search queries to my service, and eventually render search results on user front end. To do that i have found the best way was to write a Shopify App.
Here is my solution:
1, build an App, host it somewhere maybe ngrok, install it on the store: (https://help.shopify.com/api/tutorials)
2, use proxy to redirect the /apps/mysearch to where the App is hosted: (https://help.shopify.com/api/tutorials/application-proxies)
3, in the store, show users a form where action="/apps/mysearch".
4, in the app process the form data, do whatever we want. Eventually return a view back to the store containing the search result, be sure to specify "Content-Type: application/liquid" inside of the app so that the returned view works with shopify theme.
Note that all of the search happens outside of Shopify.
I think you should do this with Option 1. Though its messy but it work and save your time. You can also hire an shopify developer ( like me ) for help.
来源:https://stackoverflow.com/questions/45927777/shopify-customized-search-using-external-services