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?


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 which would enable what you're looking for.

  • Great, glad to see it's being proposed. Just upped your proposal on github. Thanks.
    – user6848
    Jun 14 '17 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.