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