Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Disabling "Show Category Counts" in Admin NOT disabling DB calls


lostndazed

Recommended Posts

Am attempting to optimize my site. Have scoured the forums for specific instructions on disabling category counts. Finally found a post where someone said to do in Admin.

 

Category count is already disabled in my admin, and I'm still getting 78 "select count (*)" calls to the database.

 

At this point, I'm thinking it may be the code modifications to includes/boxes/categories.php

 

Any ideas on a fix? Would greatly appreciate your input.

 

  function tep_show_category($counter) {
global $tree, $categories_string, $cPath_array, $aa;

for ($a=0; $a<$tree[$counter]['level']; $a++) {
//	  $categories_string .= "  ";
}

//category start
  if ($tree[$counter]['level'] == 0)
{
	if ($aa == 1)
	{
  $categories_string .= '<img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="2"><br><img src="images/pixel_ltgray.gif" border="0" alt="" width="100%" height="1"><br><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="2">';
	}
	else
	{$aa=1;}

}


// display category name
if (tep_has_category_subcategories($counter) || $tree[$counter]['level'] == 0) {
	if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
	$categories_string .= '<table class="categ"><tr><td class="categ" nowrap>' . tep_image(DIR_WS_IMAGES . 'categories/arrow_down.gif', '', '9', '9') . " </td>";
	} else {
	$categories_string .= '<table class="categ"><tr><td class="categ" nowrap>' .tep_image(DIR_WS_IMAGES . 'categories/arrow_right.gif', '', '9', '9') . " </td>";
	}
} else {
$categories_string .= '<table class="categ"><tr><td class="categ" nowrap>  ' .tep_image(DIR_WS_IMAGES . 'categories/arrow_bullet.gif', 'nokta', '9', '9') . "</td>";
}

 

 

Thank you!

Link to comment
Share on other sites

Am attempting to optimize my site. Have scoured the forums for specific instructions on disabling category counts. Finally found a post where someone said to do in Admin.

 

Category count is already disabled in my admin, and I'm still getting 78 "select count (*)" calls to the database.

 

At this point, I'm thinking it may be the code modifications to includes/boxes/categories.php

 

Any ideas on a fix? Would greatly appreciate your input.

 

  function tep_show_category($counter) {
global $tree, $categories_string, $cPath_array, $aa;

for ($a=0; $a<$tree[$counter]['level']; $a++) {
//	  $categories_string .= "  ";
}

//category start
  if ($tree[$counter]['level'] == 0)
{
	if ($aa == 1)
	{
  $categories_string .= '<img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="2"><br><img src="images/pixel_ltgray.gif" border="0" alt="" width="100%" height="1"><br><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="2">';
	}
	else
	{$aa=1;}

}
// display category name
if (tep_has_category_subcategories($counter) || $tree[$counter]['level'] == 0) {
	if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
	$categories_string .= '<table class="categ"><tr><td class="categ" nowrap>' . tep_image(DIR_WS_IMAGES . 'categories/arrow_down.gif', '', '9', '9') . " </td>";
	} else {
	$categories_string .= '<table class="categ"><tr><td class="categ" nowrap>' .tep_image(DIR_WS_IMAGES . 'categories/arrow_right.gif', '', '9', '9') . " </td>";
	}
} else {
$categories_string .= '<table class="categ"><tr><td class="categ" nowrap>  ' .tep_image(DIR_WS_IMAGES . 'categories/arrow_bullet.gif', 'nokta', '9', '9') . "</td>";
}

Thank you!

Are the numbers visible in your category box while having the setting off in Admin ?

Select count(*) is used for other purposes as the category count number also but not that many. Maybe you have some contribs in your shop which rely heavily on a select count(*) and/or STS template or something ?

The source you show has no db queries with it so can not be the problem.

The original source of the category box has the following part:

	if (SHOW_COUNTS == 'true') {
  $products_in_category = tep_count_products_in_category($counter);
  if ($products_in_category > 0) {
	$categories_string .= ' (' . $products_in_category . ')';
  }
}

The function tep_count_products_in_category() will not run if you have the admin setting for show counts set to off.

Link to comment
Share on other sites

Are the numbers visible in your category box while having the setting off in Admin ?

The function tep_count_products_in_category() will not run if you have the admin setting for show counts set to off.

 

The numbers are NOT visible in my category box because I have the setting off in Admin.

 

AH HA! The function tep_count_products_in_category() in general.php might be my culprit.

 

////
// Return the number of products in a category
// TABLES: products, products_to_categories, categories
 function tep_count_products_in_category($category_id, $include_inactive = false) {
$products_count = 0;
if ($include_inactive == true) {
  $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "'");
} else {
  $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "'");
}
$products = tep_db_fetch_array($products_query);
$products_count += $products['total'];

$child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'");
if (tep_db_num_rows($child_categories_query)) {
  while ($child_categories = tep_db_fetch_array($child_categories_query)) {
	$products_count += tep_count_products_in_category($child_categories['categories_id'], $include_inactive);
  }
}

return $products_count;
 }

 

I'll look into this later today. I guess I need to figure out how to fix this without breaking my site navigation.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...