I am trying to filter my products using craft commerce.
Is there a way to do craft.commerce.products.search("(field_color:red ORfield_color:blue) (field_size:S ORfield_size:M OR field_size:XXL)")
Or any other solution can help me achieve this filter.
Here is my code:
{% set productNumber = 12 %}
{% set priceMin = 0 %}
{% set priceMax = 1000 %}
{% set query = "(field_color:red OR field_color:blue) (field_size:S OR field_size:M OR field_size:XXL)" %}
{% set product_array = craft.commerce.products({
type:typeArray|default(""),
order:sort|default(""),
defaultPrice: [
'and',
'>= ' ~ priceMin,
'<= ' ~ priceMax,
]
}).search(query) %}
{% set product_array_limited = product_array.limit(productNumber|default("")) %}
{% paginate product_array_limited as product_array_pagenated %}
{% for product in product_array_pagenated %}
"Here is my product"
{% endfor %}
{% endpaginate %}