Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Admin modification - help requested


codefumbler

Recommended Posts

Hi

 

I would like to add a small feature to my admin area - partly because it would be useful and partly because it would be a good exercise for me in exploring some of the underlying structures and procedures in OSC.

 

In admin/stats_products_viewed.php the display shows the total views for each product but I would like to add to the bottom line a total of all views for all products.

 

I can do this manually with a SQL query but I would like some pointers on what would be the 'Acceptable OSC' way of doing this. I presume a mod to $products_query_raw would be a starting point to create a SUM variable to echo later but I would like a bit of advice if possible.

 

Also - Is there a way of affecting how many data rows display on this page (currently 5) without changing settings in other parts of the system.

 

I'd be grateful for any help

Link to comment
Share on other sites

Grr, pressed submit too soon.

 

Thats your query - now you need to wrap it into an Osc style SQL:

 

Something like:

 

$viewed_query_raw = "SELECT SUM(products_viewed) FROM " . TABLE_PRODUCTS_DESCRIPTION;



$viewed_query = tep_db_query($viewed_query_raw);



echo $viewed_query['products_viewed'];  // echo wherever you want it

Link to comment
Share on other sites

Thanks for this

I can see the logic of that and how it should work but for some reason it isn't working for me.

 

The SQL query appears to be returning an empty value

 

echo $viewed_query['products_viewed']; produces no output.

 

Any ideas where I might be going wrong??

Link to comment
Share on other sites

The following code :

 

<?php

$viewed_query_raw = "SELECT SUM(products_viewed) from " . TABLE_PRODUCTS_DESCRIPTION;

echo $viewed_query_raw ; //show the query for testing

$viewed_query = tep_db_query($viewed_query_raw);

echo "<br> total views: " . ($viewed_query) // echo wherever you want it

?>

 

Is producing this output:

 

SELECT SUM(products_viewed) from products_description

total views: Resource id #37

 

There is something I haven't got my head round here WHat is Resource ID #37? Is it perhaps returning the results as an array? Should I use AS variable in the SUM select statement?

 

I would like to solve this partly because I would like to write a general status page containing the following information:

 

Who's online

Number of product views

Number and Value of orders

Number of Registered customers

 

It would just put all the regularly monitored info in one place.

 

Any further ideas would be welcome

Link to comment
Share on other sites

I've solved it

 

This works:

 

<?php

$viewed_query_raw = "SELECT SUM(products_viewed) AS totalviews from " . TABLE_PRODUCTS_DESCRIPTION;

$viewed_query = tep_db_query($viewed_query_raw);

$row = tep_db_fetch_array($viewed_query);

echo "total views: " . $row['totalviews'] // echo wherever you want it

?>

 

Now I'll get on and build my summary report page including the following:

 

Who's online

Number of product views

Number and Value of orders

Number of Registered customers

 

I'll no doubt be back with my next problem :?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...