Assigning a product from a product-handle

4 0 1

Hi all,

I am trying to assign a product to the 'product-grid-item' snippet in the Brooklyn theme. I have copied the original snippet, creating a snippet that will hopefully pull in a single product that has been specified in the settings_schema.json file.

The code in settings_schema.json is as follows:

"type": "product",
"id": "home_content_section_1_product",
"label": "Product"

As I understand it, the output of this "id" is the product handle for the selected product (in this case let's say 'gift-card'):

{{ settings.home_content_section_1_product }}

which once tested does infact output:


What I am struggling to now understand is how to assign the selected product to the 'product-grid-item' snippet so that it will display the appropraite content for the selected product. Or maybe there is a better way of doing this?

I have tried wrapping the snippet code in the following (from Shopify Docs however this does not seem to work for me:

{% for product in collections[settings.home_content_section_1_product].products %}  
    snippet code here
{% endfor %}

Any help would be greatly appreciated, thank you.

1890 0 385

Try this:

{% assign product = all_products[settings.home_content_section_1_product] %}
{% include 'product-grid-item' %}


1 Like
4 0 1

Thank you so much, Alex!

That worked! I had assumed it would be that simple but must have tried every other combination without any luck.
Very much appreciated!