<p>If you actually have products selected in that entry's matrix products field, then</p>

<pre><code>{% for block in entry.MatrixHandle %}
  {% if block.type.handle == "matrixProductsBlockTypeHandle"%}
    {% for product in block.productsFieldHandle %}
        {{ product.title }}
    {% endfor%}
  {% endif %}
{% endfor %}
</code></pre>

<p>That is the simplest approach really.  So if that doesn't work, triple confirm the <code>entry</code> vairable is the one you think it s and that you do indeed have chosen products in that field.  If still nothing, check the <code>craft.log</code> I guess!</p>

CC BY-SA 3.0
2017-02-14T07:46:12.530Z
Great Jeremy. I ended up doing this `{% set relatedProduct = block.matrixProductsBlockFieldHandle %} {% for product in relatedProducts %} ....` works perfectly
jjem
CC BY-SA 3.0
2017-02-08T23:03:50.940Z
2017-02-08T23:03:50.940Z
Jeremy Daalder
<p>I use Matrix to select products through a "Commerce Products" field type.</p>

<p>In the template, the following code displays nothing (not even an error in devMode.)</p>

<pre><code>{% for block in entry.MatrixHandle %}
    {% set relatedProducts = craft.commerce.products.relatedTo({
        targetElement: entry, field: 'BlockTypeHandle.FieldHandle'
    }) %}

    {% for entry in relatedProducts %}
        {{ entry.title }}
    {% endfor %}

{% endfor %}
</code></pre>

CC BY-SA 3.0
2017-02-08T18:49:54.803Z
Simplify your template.  Does `{% set relatedProducts = craft.commerce.products.relatedTo({
        targetElement: entry, field: 'BlockTypeHandle.FieldHandle'
    }) %}` by itself return anything?
Brad Bell
<matrix><relations>
Commerce products in Matrix
# Commerce products in Matrix

(Asked by: username_0 on 2017-02-08)

I use Matrix to select products through a "Commerce Products" field type.
In the template, the following code displays nothing (not even an error in devMode.)
{% for block in entry.MatrixHandle %}
    {% set relatedProducts = craft.commerce.products.relatedTo({
        targetElement: entry, field: 'BlockTypeHandle.FieldHandle'
    }) %}

    {% for entry in relatedProducts %}
        {{ entry.title }}
    {% endfor %}

{% endfor %}

**Tags:** matrix, relations
> **Comments:**
> **username_1**: Simplify your template.  Does `{% set relatedProducts = craft.commerce.products.relatedTo({         targetElement: entry, field: 'BlockTypeHandle.FieldHandle'     }) %}` by itself return anything?  

---

## 1 answers

### Answer by username_2 on 2017-02-08. Score: 2 | Accepted answer

If you actually have products selected in that entry's matrix products field, then
{% for block in entry.MatrixHandle %}
  {% if block.type.handle == "matrixProductsBlockTypeHandle"%}
    {% for product in block.productsFieldHandle %}
        {{ product.title }}
    {% endfor%}
  {% endif %}
{% endfor %}

That is the simplest approach really.  So if that doesn't work, triple confirm the entry vairable is the one you think it s and that you do indeed have chosen products in that field.  If still nothing, check the craft.log I guess!

> **Comments:**
> **username_0**: Great Jeremy. I ended up doing this `{% set relatedProduct = block.matrixProductsBlockFieldHandle %} {% for product in relatedProducts %} ....` works perfectly  

---

