<p>Looks like <code>defaultPrice</code> is the property on the <code>Commerce_ProductElementType</code> class you can use for this:</p>

<p>i.e.</p>

<pre><code>{% set queryParams = {
    relatedTo: category,
        defaultPrice: [
            'and',
            '&gt;= ' ~ 200,
            '&lt;= ' ~ 500,
        ]
    }
%}
</code></pre>

CC BY-SA 3.0
2017-04-20T17:07:06.277Z
2017-04-20T17:07:06.277Z
Brad Bell
<p>I'm trying to use price as a parameter for filtering my Craft Commerce products, but I cannot get it to work. I think the problem is with the way that I'm referring to the product price, but at the same time I'm not sure how to change it so that it will work. </p>

<p>Is it possible to filter by product price as I'm trying to do here ? 
Does anyone know what exactly I need to change to get my query to work ?</p>

<p>Any pointers in the right direction would be most appreciated.  </p>

<pre><code>{% set queryParams = {
    relatedTo: category,
      price: [
       'and',
       '&gt;= ' ~ 200,
       '&lt;= ' ~ 500,
      ]
 } %}

{% set products = craft.commerce.products(queryParams) %}

{% for product in products %}
    ....output product data
{% endfor %}
</code></pre>

<plugin-craftcommerce><elementcriteriamodel><filtering>
How can I filter Craft Commerce products by price
# How can I filter Craft Commerce products by price

(Asked by: username_0 on 2017-04-20)

I'm trying to use price as a parameter for filtering my Craft Commerce products, but I cannot get it to work. I think the problem is with the way that I'm referring to the product price, but at the same time I'm not sure how to change it so that it will work. 
Is it possible to filter by product price as I'm trying to do here ? 
Does anyone know what exactly I need to change to get my query to work ?
Any pointers in the right direction would be most appreciated.  
{% set queryParams = {
    relatedTo: category,
      price: [
       'and',
       '>= ' ~ 200,
       '<= ' ~ 500,
      ]
 } %}

{% set products = craft.commerce.products(queryParams) %}

{% for product in products %}
    ....output product data
{% endfor %}

**Tags:** plugin-craftcommerce, elementcriteriamodel, filtering


---

## 1 answers

### Answer by username_1 on 2017-04-20. Score: 1 | Accepted answer

Looks like defaultPrice is the property on the Commerce_ProductElementType class you can use for this:
i.e.
{% set queryParams = {
    relatedTo: category,
        defaultPrice: [
            'and',
            '>= ' ~ 200,
            '<= ' ~ 500,
        ]
    }
%}


---

