Answers.Body: <p>I haven't tried Commerce myself but I think something like this should work:</p>
  
  <pre><code>{% set products = craft.commerce.products.type(yourType) %}
  
  //make an empty array
  {% set filteredProducts = [] %}
  
  {% for entry in products %}
      //check for your conditions
      {% if (entry.checkboxFieldhandle) or (entry.hasStock) %}
          //add each entry to your products array
          {% set filteredProducts = filteredProducts|merge([entry]) %}
      {% endif %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-27T22:33:38.550Z
Answers.Text: merge works on arrays: `filteredProducts|merge([entry])` might work.
Answers.UserDisplayName: Marion Newlevant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-27T23:24:22.360Z
Answers.Text: @MarionNewlevant you're right, edited
Answers.UserDisplayName: Jan_dh
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-30T08:11:31.567Z
Answers.Text: awesome thanks!
Answers.UserDisplayName: Branko
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-27T16:47:34.120Z
Answers.LastActivityDate: 2017-01-27T23:24:42.790Z
Answers.LastEditDate: 2017-01-27T23:24:42.790Z
Answers.UserDisplayName: Jan_dh
Body: <p>I have lots of products and I want to filter them a certain way.
  I want to retrieve all products that have stock = 1 or where product.myField = checked.</p>
  
  <p>I don't know how to do this exactly. This is what I have for now</p>
  
  <pre><code>{% for prod in craft.commerce.products({
      search: 'myField:0 or hasVariant:{hasStock:true}'   
  }).type(myType).order(sort ~ ' ' ~ order).limit(35) %}
  </code></pre>
  
  <p>Thanks in advance!</p>
  
Tags: <templating><plugin-craftcommerce>
Title: Loading specific products
ThreadText: # Loading specific products
  
  (Asked by: username_0 on 2017-01-27)
  
  I have lots of products and I want to filter them a certain way.
  I want to retrieve all products that have stock = 1 or where product.myField = checked.
  
  I don't know how to do this exactly. This is what I have for now
  
  ```
  {% for prod in craft.commerce.products({
      search: 'myField:0 or hasVariant:{hasStock:true}'   
  }).type(myType).order(sort ~ ' ' ~ order).limit(35) %}
  
  ```
  
  Thanks in advance!
  
  **Tags:** templating, plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-01-27. Score: 2 | Accepted answer
  
  I haven't tried Commerce myself but I think something like this should work:
  
  ```
  {% set products = craft.commerce.products.type(yourType) %}
  
  //make an empty array
  {% set filteredProducts = [] %}
  
  {% for entry in products %}
      //check for your conditions
      {% if (entry.checkboxFieldhandle) or (entry.hasStock) %}
          //add each entry to your products array
          {% set filteredProducts = filteredProducts|merge([entry]) %}
      {% endif %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_2**: merge works on arrays: `filteredProducts|merge([entry])` might work.  
  > **username_1**: @username_2 you're right, edited  
  > **username_0**: awesome thanks!  
  
  ---
  
  