I am working on a plugin using the getCriteria function, but for every Element Type I put, I always get an error:

No element type exists by the type “Comerce_Group”.

$criteria = craft()->elements->getCriteria("Comerce_Group");
$criteria->number = $number;
return $criteria->first();

And here is the Comerce_Group code:

class Comerce_GroupModel extends BaseModel
    protected function defineAttributes()
        return array (
            'id' => AttributeType::Number,
            'number' => AttributeType::String,
            'itemTotal' => AttributeType::Number,
  • 1
    That's not an ElementType, that's just a model. What is it you're trying to achieve? Chances are, you don't actually need a custom ElementType. Jun 7, 2017 at 14:25

1 Answer 1


As Stephen pointed out, you're getting that error because your Commerce_GroupModel class is a Model that extends BaseModel, not an Element Type, which is what ElementsService->getCriteria() is looking for.

Are you sure you actually need a custom element type here? Depending on what you're going for, Models might be enough.

  • i wish to search the commerce groups and then return the one with a specific identification number to see if it exist and then further process it , i wanted to avoid doing this though DB querys, i got the idea while looking over the Craft Commerce plugin
    – Abraham
    Jun 8, 2017 at 8:19
  • Assuming you've got a Commerce_GroupRecord defined in your plugin that tied to to a database table for persistent storage?
    – Brad Bell
    Jun 8, 2017 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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