How to check entity is already created? I have the code that create entity named "Victory" in entity type, my problem is how to prevent user creates the entity with the same name again.

function commerce_services_store_create($data, $flatten_fields) {
  $storeName = $data['store_name'];
  $status = 1;


  $entityType = "fruit_store";       //entity type name Fruit Store                         
  $entity = entity_create($entityType, array('type' =&gt; "store")); //bundle store
  $entityWrapper= entity_metadata_wrapper($entityType,$entity);  // create entity named "Victory" 
  $entityWrapper-&gt;title-&gt;set($storeName);
  $entityWrapper-&gt;save();

  $store_id = $entityWrapper-&gt;id-&gt; value();   
  if($store_id != null){
    $reply= (array('status' =&gt; $status,'result' =&gt;"Your store name ". $storeName. " Store id is ". $store_id));
  }else{
    $status = 0;
    $result = "Can't create store.";
    $reply = $reply= array('status' =&gt; $status,'result' =&gt; $result);
  }

  return $reply;

}
Just like validating the user email in any system you check if its already exists or not, in your case we need to check that we have no entity with the same attribute value exists:

$query = new EntityFieldQuery();

$query-&gt;entityCondition('entity_type', 'Fruit_Store')
  -&gt;entityCondition('bundle', 'store')
  // this is a condition for the entity field values
  -&gt;fieldCondition('field_title', 'value', 'spotlight', '=');

$result = $query-&gt;execute();

if (!empty($result['Fruit_Store'])) {
  // entity already exsits.
}
else{
  // add new entity
}


you can find more information about EntityFieldQuery in this page:

https://www.drupal.org/node/1343708