Listing all available default variants Folks:

I figured this would be simple but apparently not (for me, anyway).


I have a product with two variants (orange and yellow).
I have a page that lists all the available products.
On that page, both variants appear. I really just need one and users
can select their variant from a drop-down on the checkout page.


What I've got:

{# get the products from the categories #}
{% set products = craft.commerce.products.type('shirts,shorts') %}

{# show the product main image and link to the product page #}
&lt;a href="{{ product.url }}"&gt;
    {% if product|length %}
        {% set asset = product.productHeroImage.first() %}
    &lt;img src="{{ asset.url }}"&gt;{% endif %}
&lt;/a&gt;


I did try {% set products = craft.commerce.products.defaultVariant.type('shirts,shorts') %} but get the same results.
OK, so this did have a really simple solution. Just use isDefault.

{% if variant.isDefault %}Show the product{% endif %}


Works like a charm.