How do I retrieve a specific product in Shopify Liquid?

jayshields picture jayshields · Nov 7, 2012 · Viewed 25.9k times · Source

I have a list of product handles, and I want to fetch the product based on this handle. It seems there is no way to tell Liquid to go and get a single product. I could do this with the API, but if I use the API then I have to use JavaScript, and I would have to copy the HTML which I already have in a snippet, and copy the logic too.

A cut down version of what I am attempting:

{% assign handle = 'my-product-handle' %}
{% assign product = products.handle %}
{% include 'snippet-product-item' %}

Answer

Jason picture Jason · Jun 15, 2015

You can now retrieve a product via a handle using the following:

{% assign someProduct = all_products.some-handle %}

There's currently no documentation to back this up, but hopefully there'll be something tangible on Shopify side soon.