Answers.Body: <p>As <a href="https://craftcms.stackexchange.com/questions/20732/no-element-type-exists-with-getcriteria-and-custom-element-type/20740#comment27848_20732">Stephen</a> pointed out, you're getting that error because your <code>Commerce_GroupModel</code> class is a <a href="https://craftcms.com/docs/plugins/models" rel="nofollow noreferrer">Model</a> that extends <code>BaseModel</code>, not an <a href="https://pixelandtonic.com/blog/craft-element-types" rel="nofollow noreferrer">Element</a> <a href="https://straightupcraft.com/events/introduction-to-element-types-in-craft-cms-part-1-of-3" rel="nofollow noreferrer">Type</a>, which is what <code>ElementsService-&gt;getCriteria()</code> is looking for.</p>
  
  <p>Are you sure you actually need a custom element type here?  Depending on what you're going for, Models might be enough.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-08T08:19:19.677Z
Answers.Text: 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
Answers.UserDisplayName: Abraham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-08T22:47:54.280Z
Answers.Text: Assuming you've got a `Commerce_GroupRecord` defined in your plugin that tied to to a database table for persistent storage?
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-07T22:50:15.650Z
Answers.LastActivityDate: 2017-06-07T22:50:15.650Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am working on a plugin using the getCriteria function, but for every Element Type I put, I always get an error:</p>
  
  <blockquote>
    <p>No element type exists by the type “Comerce_Group”.</p>
  </blockquote>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria("Comerce_Group");
  $criteria-&gt;number = $number;
  return $criteria-&gt;first();
  </code></pre>
  
  <p>And here is the Comerce_Group code:</p>
  
  <pre><code>class Comerce_GroupModel extends BaseModel
  {  
      protected function defineAttributes()
      {
          return array (
              'id' =&gt; AttributeType::Number,
              'number' =&gt; AttributeType::String,
              'itemTotal' =&gt; AttributeType::Number,
          );
      }    
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-07T14:25:00.070Z
Comments.Text: 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.
Comments.UserDisplayName: Stephen Lewis
Tags: <plugin-development><plugin-craftcommerce><elementcriteriamodel><models><custom>
Title: no element type exists with getCriteria and custom element type
ThreadText: # no element type exists with getCriteria and custom element type
  
  (Asked by: username_0 on 2017-06-07)
  
  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,
          );
      }    
  }
  
  ```
  
  **Tags:** plugin-development, plugin-craftcommerce, elementcriteriamodel, models, custom
  
  > **Comments:**
  > **username_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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-06-07. Score: 1
  
  As [username_1](https://craftcms.stackexchange.com/questions/20732/no-element-type-exists-with-getcriteria-and-custom-element-type/20740#comment27848_20732) pointed out, you're getting that error because your `Commerce_GroupModel` class is a [Model](https://craftcms.com/docs/plugins/models) that extends `BaseModel`, not an [Element](https://pixelandtonic.com/blog/craft-element-types) [Type](https://straightupcraft.com/events/introduction-to-element-types-in-craft-cms-part-1-of-3), 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.
  
  > **Comments:**
  > **username_0**: 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  
  > **username_2**: Assuming you've got a `Commerce_GroupRecord` defined in your plugin that tied to to a database table for persistent storage?  
  
  ---
  
  