<p>I managed to resolve this using the <a href="https://github.com/TopShelfCraft/SuperSort" rel="nofollow noreferrer">supersort</a> plugin and using 'defaultPrice' instead of 'price'. Example below:</p>

<pre><code>{% set products = craft.products.type('accommodation').all() %}
{% set order = products|supersort('sortAs', '{{ object.defaultPrice }}') %}

{% for product in order %}

    // Products

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

CC BY-SA 4.0
2019-01-02T14:18:48.517Z
2019-01-02T14:18:48.517Z
Amy
<p>Currently using Craft Commerce 2. </p>

<p>I was wondering if it's possible to order products by the lowest priced variant. I have tried something along the lines of this, but it doesn't do anything different with the ordering:</p>

<pre><code>{% set products = craft.products.type('accommodation').all() %}

{% for product in products %}
   {% if product.getVariants()|length %}

        {% set variants = craft.variants ({
            product: product,
            orderBy: 'price asc'
        }) %}

        {% for purchasable in variants %}
            // Products Here
        {% endfor %}

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

<p>I have also tried something else along the lines of this:</p>

<pre><code>{% set products = craft.commerce.products({
    relatedTo: 'accommodation', 
    order: 'defaultPrice asc',
}) %}
</code></pre>

<craft3><plugin-craftcommerce2><order><variants>
Order products by lowest product variant
# Order products by lowest product variant

(Asked by: username_0 on 2018-12-20)

Currently using Craft Commerce 2. 
I was wondering if it's possible to order products by the lowest priced variant. I have tried something along the lines of this, but it doesn't do anything different with the ordering:
{% set products = craft.products.type('accommodation').all() %}

{% for product in products %}
   {% if product.getVariants()|length %}

        {% set variants = craft.variants ({
            product: product,
            orderBy: 'price asc'
        }) %}

        {% for purchasable in variants %}
            // Products Here
        {% endfor %}

    {% endif %}
{% endfor %}

I have also tried something else along the lines of this:
{% set products = craft.commerce.products({
    relatedTo: 'accommodation', 
    order: 'defaultPrice asc',
}) %}

**Tags:** craft3, plugin-craftcommerce2, order, variants

---

## 1 answers

### Answer by username_0 on 2019-01-02. Score: 2 | Accepted answer

I managed to resolve this using the supersort plugin and using 'defaultPrice' instead of 'price'. Example below:
{% set products = craft.products.type('accommodation').all() %}
{% set order = products|supersort('sortAs', '{{ object.defaultPrice }}') %}

{% for product in order %}

    // Products

{% endfor %}


---

