Skip to content

Instantly share code, notes, and snippets.

@michelarteta
Last active April 10, 2021 14:08
Show Gist options
  • Save michelarteta/afff2c3acc47a4c4a93b902f4e77142d to your computer and use it in GitHub Desktop.
Save michelarteta/afff2c3acc47a4c4a93b902f4e77142d to your computer and use it in GitHub Desktop.
Shopify SKU Search Endpoint
{%- 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