Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help, How to display total number of catalog items ?


Fab Miller

Recommended Posts

Hello, I would like to know how to display a total number of active catalog items and I am hoping this is as simple as adding a line of code somewhere :rolleyes: . As all the catalog items are of mostly 1 quantity, is it possible to add all the category totals to get this number and display it? I would prefer the total in the categories box somewhere but not too critical. :P

 

Thanks for any help, Fab

Link to comment
Share on other sites

Look in /includes/footer.php for a good example of displaying data extracted from an sql table.

 

How to obtain this information in a efficient way is the question. You could run a daily job to count the no of records in the products table and store it in a new field on the counter table.

 

This link should help

 

http://dev.mysql.com/doc/refman/5.1/en/gro...#function_count

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites

goto your admin section (www.yourdomain.com/catalog/admin/) then click on configuration then My Store and set Show Category Counts to true ... is that what u were after??

Link to comment
Share on other sites

Look in /includes/footer.php for a good example of displaying data extracted from an sql table.

 

How to obtain this information in a efficient way is the question. You could run a daily job to count the no of records in the products table and store it in a new field on the counter table.

 

This link should help

 

http://dev.mysql.com/doc/refman/5.1/en/gro...#function_count

 

 

Thanks Geoffrey, But I am fairly new to this PHP stuff. I can understand that it needs to be a little more complicated and efficient code too. I would have no idea what the code would be or where to put the code. Is this the code from above you are referring to

 

SELECT COUNT(*) FROM student; (replacing student with products?)

 

Thanks Fab

Link to comment
Share on other sites

goto your admin section (www.yourdomain.com/catalog/admin/) then click on configuration then My Store and set Show Category Counts to true ... is that what u were after??

 

Hi sLaV, I was after the total of all these numbers (total of all unique products in catalog), then to display it in the category.php box

 

Cheers Fab ;)

Link to comment
Share on other sites

Hi sLaV, I was after the total of all these numbers (total of all unique products in catalog), then to display it in the category.php box

 

Cheers Fab ;)

 

This SQL query will give you the total number of ACTIVE products in your database:

 SELECT count( * )
FROM `products`
WHERE products_status =1

 

so store that call in a PHP variable: $totalsqlproducts = "SELECT count(*) from " . TABLE_PRODUCTS . " where products_status = '1'";

run the SQL query storing the result in a variable...display that variable :)

Link to comment
Share on other sites

Being the MYSQL idiot that I am, I came up with a way to do it using just PHP:

 

<?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]);
 } 
}
// the variable $total now contains the number of active products
?>

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...