Search code examples
producthandleshopifyliquid

How do I retrieve a specific product in Shopify Liquid?


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' %}

Solution

  • 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.