Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hiding Product Categories for Empty Categories


mreigle

Recommended Posts

As the title says, I want to hide my product Categories on the main page that don't have any products. I've installed the Enable & Disable Categories (http://www.oscommerce.com/community/contributions,326) contribution several times, but I can't find any way to make it work with my site. It adds green/red buttons to /admin/categories.php like the product options page does in the admin section, but the code seems to be pretty buggy. Changing a button to red will remove the products from the category, but won't make the catalog disappear from the main page. I've posted this in the support thread for that particular contribution but haven't gotten any answers back yet.

 

I've also searched in the forums many times and could not find any solutions that are legitimate. I found a few broken links though...

 

Is there any way to make the categories disappear from the main page in another way?

 

Has anyone else had any similiar problems to this?

Link to comment
Share on other sites

Man, thanks. That made my head spin. That's definitely the worst documented contribution I've ever encountered.... I don't even want to install that mumbo jumbo.

 

I can't be the first person to have this much trouble, but it's sure looking like that.

Link to comment
Share on other sites

well the other option is to do it yourself here is a start you need to modify the catalog\index.php where there is code to list the categories.

 

So find this code:

 

	$rows = 0;
while ($categories = tep_db_fetch_array($categories_query)) {
  $rows++;
  $cPath_new = tep_get_path($categories['categories_id']);
  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
  echo '				<td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n";
  if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
	echo '			  </tr>' . "\n";
	echo '			  <tr>' . "\n";
  }
}

 

Replace it with this:

	$rows = 0;
while ($categories = tep_db_fetch_array($categories_query)) {

  $products_in_category = tep_count_products_in_category($categories['categories_id']);
  if ($products_in_category > 0) {
  $rows++;
  $cPath_new = tep_get_path($categories['categories_id']);
  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
  echo '				<td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n";
  if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
	echo '			  </tr>' . "\n";
	echo '			  <tr>' . "\n";
  }
}
}

Of course haven't tested anything just glued it together so backup files before doing anything.

Link to comment
Share on other sites

enigma1, is it possible to achieve this affect with manufacturers too?

after initially reading this topic i did a number of searches but found nothing :(

Link to comment
Share on other sites

but the manufacturers do not have categories. The products have a manufacturers_id in them. Or you mean listing only the manufacturers that have products?

Link to comment
Share on other sites

Thanks, I'll try that code in just one sec. I'm still learning PHP and I'm trying to install this god forsaken "Enable Disable Categories" contribution once again. I've got it all installed but index.php keeps throwing me parse errors. I've worked through a couple of them, but I can't figure out what's wrong here:

 

 

(sorry its so long)

 

Parse error: parse error, unexpected T_ELSEIF in /home/precious/public_html/index.php on line 99

 

<?php
require('includes/application_top.php');
// the following cPath references come from application_top.php
$category_depth = 'top';
if (isset($cPath) && tep_not_null($cPath)) {
$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
$cateqories_products = tep_db_fetch_array($categories_products_query);
if ($cateqories_products['total'] > 0) {
$category_depth = 'products'; // display products
} else {
$category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
$category_parent = tep_db_fetch_array($category_parent_query);
if ($category_parent['total'] > 0) {
$category_depth = 'nested'; // navigate through the categories
} else {
$category_depth = 'products'; // category has no products, but display the 'no products' message
}
}
}
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html <?php echo HTML_PARAMS; ?>><head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<?php
// RJW Begin Meta Tags Code
if (file_exists(DIR_WS_INCLUDES . 'meta_tags.php')) {
 require(DIR_WS_INCLUDES . 'meta_tags.php');
} else {
?>
<title><?php echo TITLE ?></title>
<?php }
// RJW End Meta Tags Code
?> 
<meta name="copyright" content="2006, Precious Bedding">
<meta name="author" content="Matthew Reigle">
<meta name="robots" content="FOLLOW, INDEX">
<meta name="language" content="English">
<meta name="Rating" content="General">
<meta name="distribution" content="Global">
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<script language="JavaScript" src="//www.preciousbedding.com/window_size.js" type="text/javascript"></script>
</head>
<body>
</td>
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<table class="m_table">
<tr>
<?php
if ($category_depth == 'nested') {
$category_query = tep_db_query("select cd.categories_name, c.categories_image, cd.categories_htc_title_tag, cd.categories_htc_description from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
$category = tep_db_fetch_array($category_query);
?>
<td width="100%" valign="top">
<table class="m_table">
<tr><td>
<table class="n_table">
<tr><td>
<table class="n_table">
<tr>
<?php
if (isset($cPath) && strpos('_', $cPath)) {
// check to see if there are deeper categories within the current category
$category_links = array_reverse($cPath_array);
for($i=0, $n=sizeof($category_links); $i<$n; $i++) {
$categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
	$categories = tep_db_fetch_array($categories_query);
	if ($categories['total'] < 1) {
	  // do nothing, go through the loop
	} else {
$categories = tep_db_fetch_array($categories_query);
if ($categories['total'] < 1) {
// do nothing, go through the loop
} else {
$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
break; // we've found the deepest category the customer is in
}
$number_of_categories = tep_db_num_rows($categories_query);
$rows = 0;
while ($categories = tep_db_fetch_array($categories_query)) {
$rows++;
$cPath_new = tep_get_path($categories['categories_id']);
$width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n";
if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
echo ' </tr>' . "\n";
echo ' <tr>' . "\n";
}
}
// needed for the new products module shown below
$new_products_category_id = $current_category_id;
?>
</tr></table></td></tr><tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr><tr><td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
</tr></table></td></tr></table></td>
<?php
} elseif ($category_depth == 'products' || isset($HTTP_GET_VARS['manufacturers_id'])) {
// create column list
$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);
asort($define_list);
$column_list = array();
reset($define_list);
while (list($key, $value) = each($define_list)) {
if ($value > 0) $column_list[] = $key;
}
$select_column_list = '';
for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
switch ($column_list[$i]) {
case 'PRODUCT_LIST_MODEL':
$select_column_list .= 'p.products_model, ';
break;
case 'PRODUCT_LIST_NAME':
$select_column_list .= 'pd.products_name, ';
break;
case 'PRODUCT_LIST_MANUFACTURER':
$select_column_list .= 'm.manufacturers_name, ';
break;
case 'PRODUCT_LIST_QUANTITY':
$select_column_list .= 'p.products_quantity, ';
break;
case 'PRODUCT_LIST_IMAGE':
$select_column_list .= 'p.products_image, ';
break;
case 'PRODUCT_LIST_WEIGHT':
$select_column_list .= 'p.products_weight, ';
break;
}
}
// show the products of a specified manufacturer
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";

} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
}
} else {
// show the products in a given categorie
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_CATEGORIES . " c on c.categories_id = p2c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_CATEGORIES . " c on c.categories_id = p2c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
}
}
if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
$HTTP_GET_VARS['sort'] = $i+1 . 'a';
$listing_sql .= " order by pd.products_name";
break;
}
}
} else {
$sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
$sort_order = substr($HTTP_GET_VARS['sort'], 1);
$listing_sql .= ' order by ';
switch ($column_list[$sort_col-1]) {
case 'PRODUCT_LIST_MODEL':
$listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_NAME':
$listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
break;
case 'PRODUCT_LIST_MANUFACTURER':
$listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_QUANTITY':
$listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_IMAGE':
$listing_sql .= "pd.products_name";
break;
case 'PRODUCT_LIST_WEIGHT':
$listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_PRICE':
$listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
}
}
?>
<td width="100%" valign="top"><table>
<tr><td>
<?php
$category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
$category = tep_db_fetch_array($category_query);
include( 'includes/descriptions/'.$category['categories_name'].'.php' );
?>
<?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?></td>
</tr>
(cut the end off to shorten it)

Link to comment
Share on other sites

you have a bunch of curly brackets missing

 

}
}
// needed for the new products module shown below

 

should been

}
}
}
}
}
// needed for the new products module shown below

Link to comment
Share on other sites

as of the manufacturers, you could use the same code I posted but call a separate function like tep_count_products_in_manufacturers by duplicating the tep_count_products_in_category. Then in the where clauses set the extra condition of "manufacturer_id not null"

Link to comment
Share on other sites

  • 2 weeks later...
as of the manufacturers, you could use the same code I posted but call a separate function like tep_count_products_in_manufacturers by duplicating the tep_count_products_in_category. Then in the where clauses set the extra condition of "manufacturer_id not null"

not finding any "where"s

 

i have this:

	$manufacturers_query = tep_db_query("select manufacturers_name, manufacturers_id, manufacturers_image from " . TABLE_MANUFACTURERS . " order by manufacturers_name" );

$mans_array = array();

while ($mans_array[] = tep_db_fetch_array($manufacturers_query));

array_pop($mans_array);

$max=count($mans_array);

if( $max > MAX_DISPLAY_CATEGORIES_PER_ROW ) {

  $col_height = intval($max/MAX_DISPLAY_CATEGORIES_PER_ROW);

  $cross = $col_height*MAX_DISPLAY_CATEGORIES_PER_ROW;

  $tmp_array = array();

  for( $i=0, $offset=0; $i<$max && $offset<MAX_DISPLAY_CATEGORIES_PER_ROW; $offset++ ) {

	for( $j=$offset; $j<$cross && $i<$max; $i++ ) {

	  if($j < $max ) {

		$tmp_array[$j] = $mans_array[$i];

		$j+=MAX_DISPLAY_CATEGORIES_PER_ROW;

	  }

	}

  }

  $mans_array = $tmp_array;

  unset($tmp_array);

}

 

 

 

 

 

 

 

 

 

 

 

and back on topic, this is the code i use to hide categories & subcategories:

//  Show only if category has products - Hack 1 - Start
 $any_products = tep_count_products_in_category($categories['categories_id']);

if ($any_products > 0) {

//  Show only if category has products - Hack 1 - End
			$rows++;
			$cPath_new = tep_get_path($categories['categories_id']);
			$width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
			echo '				<td align="center" valign="top" width="205"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories['categories_name'] . '</a></td>' . "\n";
//  Show only if category has products - Hack 2 - Start

 }

//  Show only if category has products - Hack 2 - End

i can't be specific of what to find & replace, because i found this hack several months ago on these forums

Link to comment
Share on other sites

post the function you made "tep_count_products_in_manufacturers" You should have an sql query there that needs to filter the manufacturer id. Have you done that? because I do not see it from the code you posted.

Link to comment
Share on other sites

oh, sorry... i posted my original manufacturers page

 

$manufacturers_query = tep_db_query("select manufacturers_name, manufacturers_id, manufacturers_image from " . TABLE_MANUFACTURERS . " order by manufacturers_name" );

$mans_array = array();

while ($mans_array[] = tep_db_fetch_array($manufacturers_query));
$manufacturers_in_category = tep_count_manufacturers_in_category($manufacturers['manufacturers_id']);
array_pop($mans_array);

$max=count($mans_array);

if( $max > MAX_DISPLAY_CATEGORIES_PER_ROW ) {

$col_height = intval($max/MAX_DISPLAY_CATEGORIES_PER_ROW);

$cross = $col_height*MAX_DISPLAY_CATEGORIES_PER_ROW;

$tmp_array = array();

for( $i=0, $offset=0; $i<$max && $offset<MAX_DISPLAY_CATEGORIES_PER_ROW; $offset++ ) {

for( $j=$offset; $j<$cross && $i<$max; $i++ ) {

if($j < $max ) {

$tmp_array[$j] = $mans_array[$i];

$j+=MAX_DISPLAY_CATEGORIES_PER_ROW;

}

}

}

}

$mans_array = $tmp_array;

unset($tmp_array);

}

Link to comment
Share on other sites

I still do not see the function. I only see where you're doing the function call. Should be in the general.php that you added that right?

Link to comment
Share on other sites

i'm a bit confused.. so i add:

$manufacturers_in_category = tep_count_manufacturers_in_category($manufacturers['manufacturers_id']);

 

in general.php instead of on my manufacturer's page?

Link to comment
Share on other sites

no, you should make an equivalent function like tep_count_products_in_category. See how this function is setup in general.php file and duplicate it with a different name first. Then you change the query as I mentioned.

 

Once you have it then you can use it with the main catalog files.

Link to comment
Share on other sites

i tried

  function tep_count_products_in_manufacturer($manufacturer_id, $include_inactive = false) {
$products_in_manufacturer_count = 0;
if ($include_inactive == true) {
  $products_in_manufacturer_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . MANUFACUTRERS_ID . " p2c where p.manufacturers_id = p2c.products_id and p2c.manufacturers_id = '" . (int)$manufacturers_id . "'");
} else {
  $products_in_manufacturer = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . MANUFACTURERS_ID . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.manufacturers_id = '" . (int)$manufacturers_id . "'");
}
$products = tep_db_fetch_array($products_query);
$products_count += $products['total'];

}

return $products_count;
 }

 

but got:

Parse error: parse error, unexpected '}' in /home/**/public_html/TESTSHOP/includes/functions/general.php on line 423

 

 

line 423:

}

(ending of the new function i added)

Link to comment
Share on other sites

yea has a bunch of errors.

 

try this should count the number of products for a manufacturer.

 

  function tep_count_products_in_manufacturer($manufacturers_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_MANUFACTURERS . " m where p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$manufacturers_id . "'");
} else {
  $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_MANUFACTURERS . " m where p.manufacturers_id = m.manufacturers_id and p.products_status = '1' and p.manufacturers_id = '" . (int)$manufacturers_id . "'");
}
$products = tep_db_fetch_array($products_query);
$products_count += $products['total'];
return $products_count;
 }

Link to comment
Share on other sites

thanks, no errors there.

now when i try to put this in my /manufacturers.php (all manufacturers contrib) am i putting this in the wrong spot?

 

beneath:

$width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';

for($i=0; $i<$max; $i++ ) {

 

i added

if ($manufacturers_in_category > 0) {

 

 

and above

echo '</td>';

 

i added

}

 

and all manufacturers (even those with products) are hidden

Link to comment
Share on other sites

so you have this code in the allmanufacturers.php page

 

	while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
  $row++;
  echo '<td align="center" valign="top" width="25%" class="smallText">';
  echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id'] . '=' . $manufacturers['manufacturers_name'], 'NONSSL', false) . '">' . tep_image(DIR_WS_IMAGES . $manufacturers['manufacturers_image'], $manufacturers['manufacturers_name']) . "</a><br><br>\n";
  echo '</td>';

 

call the function to get the manufacturer product count so add below it

echo '<td align="center" valign="top" width="25%" class="smallText">' . tep_count_products_in_manufacturer($manufacturers['manufacturers_id']) . '</td>';

to get the product count per manufacturer.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...