Last active
April 10, 2021 14:08
-
-
Save michelarteta/afff2c3acc47a4c4a93b902f4e77142d to your computer and use it in GitHub Desktop.
Shopify SKU Search Endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%- layout none -%} | |
{%- comment -%} | |
/* | |
* Shopify SKU Search Endpoint | |
* `/search?type=product&q=${searchValue}&view=json` | |
* | |
*/ | |
{%- endcomment -%} | |
{% capture results %} | |
{% for item in search.results %} | |
{% assign product = item %} | |
{ | |
"title" : {{ product.title | json }}, | |
"variants" : {{ product.variants | json }}, | |
"url" : {{ product.url | within: product.collections.last | json }}, | |
"thumbnail": {{ product.featured_image.src | img_url: '100x' | json }}, | |
"thumbnail_alt": {{ product.featured_image.alt | json }} | |
} | |
{% unless forloop.last %},{% endunless %} | |
{% endfor %} | |
{% endcapture %} | |
{ | |
"results_count": {{ search.results_count }}, | |
"results": [{{ results }}] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment