diff --git a/modules/product/includes/commerce_product_ui.types.inc b/modules/product/includes/commerce_product_ui.types.inc
index 428a94a..000cb53 100644
--- a/modules/product/includes/commerce_product_ui.types.inc
+++ b/modules/product/includes/commerce_product_ui.types.inc
@@ -120,8 +120,17 @@ function commerce_product_ui_product_type_delete_form_wrapper($type) {
   }
 
   // Don't allow deletion of product types that have products already.
-  if (($count = db_query("SELECT product_id FROM {commerce_product} WHERE type = :product_type", array(':product_type' => $product_type['type']))->rowCount()) > 0) {
+  $query = new EntityFieldQuery();
+
+  $query->entityCondition('entity_type', 'commerce_product', '=')
+    ->entityCondition('bundle', $product_type['type'], '=')
+    ->count();
+
+  $count = $query->execute();
+
+  if ($count > 0) {
     drupal_set_title(t('Cannot delete the %name product type', array('%name' => $product_type['name'])), PASS_THROUGH);
+
     return format_plural($count,
       'There is 1 product of this type. It cannot be deleted.',
       'There are @count products of this type. It cannot be deleted.'
diff --git a/modules/product/tests/commerce_product_ui.test b/modules/product/tests/commerce_product_ui.test
index 34ce78b..2c70225 100644
--- a/modules/product/tests/commerce_product_ui.test
+++ b/modules/product/tests/commerce_product_ui.test
@@ -511,12 +511,21 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase {
     // deleted.
     $this->pass(t('Product type has at least one product, test the validation messages:'));
     $this->assertTitle(t('Cannot delete the !name product type', array('!name' => $product_types['product']['name'])) . ' | Drupal', t('Validation title of the page displayed correctly.'));
+
     // Get the count of products of the type
-    $count = db_query("SELECT product_id FROM {commerce_product} WHERE type = :product_type", array(':product_type' => $product_types['product']['type']))->rowCount();
+    $query = new EntityFieldQuery();
+
+    $query->entityCondition('entity_type', 'commerce_product', '=')
+      ->entityCondition('bundle', $product_type['type'], '=')
+      ->count();
+
+    $count = $query->execute();
+
     $message = format_plural($count,
       'There is 1 product of this type. It cannot be deleted.',
       'There are @count products of this type. It cannot be deleted.'
     );
+
     $this->assertText($message, t('Display the reason why the product type cannot be deleted and show the number of products related to it'));
   }
 
diff --git a/modules/product_pricing/includes/commerce_product_pricing_ui.admin.inc b/modules/product_pricing/includes/commerce_product_pricing_ui.admin.inc
index 8f035cf..6e5d3e4 100644
--- a/modules/product_pricing/includes/commerce_product_pricing_ui.admin.inc
+++ b/modules/product_pricing/includes/commerce_product_pricing_ui.admin.inc
@@ -37,10 +37,10 @@ function commerce_product_pre_calculation_settings_form($form, &$form_state) {
     ->fields('commerce_calculated_price', array('created'))
     ->condition('module', 'commerce_product_pricing')
     ->condition('entity_type', 'commerce_product')
-    ->condition('field_name', 'commerce_price')
-    ->execute();
+    ->condition('field_name', 'commerce_price');
 
-  $count = $query->rowCount();
+  $count_query = clone($query);
+  $count = $count_query->countQuery()->execute()->fetchField();
 
   // If there are rows in the table or price pre-calculation is enabled, show
   // the management fieldset with its action buttons.
@@ -53,7 +53,7 @@ function commerce_product_pre_calculation_settings_form($form, &$form_state) {
 
     // If there are prices, add the timestamp for the last calculation.
     if ($count > 0) {
-      $description .= ' ' . t('The last calculation occured on @date.', array('@date' => format_date($query->fetchField(), 'short')));
+      $description .= ' ' . t('The last calculation occured on @date.', array('@date' => format_date($query->execute()->fetchField(), 'short')));
     }
 
     $form['database'] = array(
diff --git a/modules/tax/includes/commerce_tax_ui.admin.inc b/modules/tax/includes/commerce_tax_ui.admin.inc
index e98d05b..1fde2c5 100644
--- a/modules/tax/includes/commerce_tax_ui.admin.inc
+++ b/modules/tax/includes/commerce_tax_ui.admin.inc
@@ -481,8 +481,16 @@ function commerce_tax_ui_tax_type_delete_form_wrapper($tax_type) {
   }
 
   // Don't allow deletion of tax types that have tax rates.
-  if (($count = db_query("SELECT name FROM {commerce_tax_rate} WHERE type = :tax_type", array(':tax_type' => $tax_type['name']))->rowCount()) > 0) {
+  $query = db_select('commerce_tax_rate')
+    ->condition('type', $tax_type['name'])
+    ->countQuery()
+    ->execute();
+
+  $count = $query->fetchField();
+
+  if ($count > 0) {
     drupal_set_title(t('Cannot delete the %title tax type', array('%title' => $tax_type['title'])), PASS_THROUGH);
+
     return format_plural($count,
       'There is a tax rate of this type. It cannot be deleted.',
       'There are @count tax rates of this type. It cannot be deleted.'
