<p>This is more of a limitation of Craft than Commerce, but it's currently not possible in one query... you'd need to do two and perform some merging/filtering logic.</p>

<p>Consider thumbs-upping/commenting on <a href="https://github.com/craftcms/cms/issues/878" rel="nofollow noreferrer">this feature request</a> which would enable what you're looking for.</p>

CC BY-SA 3.0
2017-06-14T04:31:39.117Z
Great, glad to see it's being proposed. Just upped your proposal on github. Thanks.
user6848
CC BY-SA 3.0
2017-06-14T04:21:13.077Z
2017-06-14T04:21:13.077Z
Brad Bell
<p>I have Craft Commerce installed, and I wanted to search title against both product title and variant title. I looked up in the database, I noticed that products and variants are of two element types, <code>Commerce_Product</code> and <code>Commerce_Variant</code>. As far as I know, with <code>ElementCriteriaModel</code> you can only query against one element type, like what I have now:</p>

<pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria('Commerce_Product');
</code></pre>

<p>Is it possible to query against multiple element types in one db call?</p>

<plugin-craftcommerce><craft-features>
How do I query multiple element types in one query
# How do I query multiple element types in one query

(Asked by: username_0 on 2017-06-14)

I have Craft Commerce installed, and I wanted to search title against both product title and variant title. I looked up in the database, I noticed that products and variants are of two element types, Commerce_Product and Commerce_Variant. As far as I know, with ElementCriteriaModel you can only query against one element type, like what I have now:
$criteria = craft()->elements->getCriteria('Commerce_Product');

Is it possible to query against multiple element types in one db call?

**Tags:** plugin-craftcommerce, craft-features

---

## 1 answers

### Answer by username_1 on 2017-06-14. Score: 0 | Accepted answer

This is more of a limitation of Craft than Commerce, but it's currently not possible in one query... you'd need to do two and perform some merging/filtering logic.

Consider thumbs-upping/commenting on [this feature request](https://github.com/craftcms/cms/issues/878) which would enable what you're looking for.

> **Comments:**
> **username_0**: Great, glad to see it's being proposed. Just upped your proposal on github. Thanks.  

---

