Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Total Number of Products


Cyperis

Recommended Posts

As the topic states Im trying to find a way to display that on a page. I have searched for a while and all I have been able to find is a way to display the stock level of a product.

 

Any help with this would be appreciated.

Link to comment
Share on other sites

<?php echo tep_get_products_stock($product_id); ?>

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Disregard my last post.

 

Stupid should hurt...

:huh:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

<?php
$categories_array = array();
tep_get_subcategories($categories_array);
$n = count($categories_array);
$total = 0;
for ( $i = 0 ; $i < $n ; $i++) {
 if ( ! tep_has_category_subcategories($categories_array[$i]) ) {
 $total += tep_count_products_in_category($categories_array[$i]);
 }
}
echo $total;
?>

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Thanks, that's exactly what I was looking for. What about taking that another step forward, is there also a way to show total number of catgories and manufacturers?

Link to comment
Share on other sites

New code:

 

<?php
 $categories_array = array();
 tep_get_subcategories($categories_array);
 $n = count($categories_array);
// Total categories = $n
 $total = 0;
 for ( $i = 0 ; $i < $n ; $i++) {
if ( ! tep_has_category_subcategories($categories_array[$i]) ) {
  $total += tep_count_products_in_category($categories_array[$i]);
}
 }
// Total products = $total
 $m = 0;
 $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS);
 if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
  ++$m;
}
 }
//Total manufacturers = $m
?>

 

After that code executes:

 

To display total categories:

 

<?php echo $n; ?>

 

To display total products:

 

<?php echo $total; ?>

 

To display total manufacturers:

 

<?php echo $m; ?>

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...