chrometweaks.org

Whats is the best website hoster iPage or?

Click Here To View All Answers...


Quick question... Whats is the best website hoster iPage or? Looking forward for any response. 2nd question I got is.. Hi,.

I posted this on General Support but was so quickly drowned out by other post, that I decided to should try here instead..

Basically, I want to implement a sales ranking like Amazon's..

How do I get the number ranking at "admin/stats_products_purchased.php" to appear on products_info.php?.

For example:.

No. Products.

01. A Bug's Life.

02. Blade Runner - Director's Cut.

03. Courage Under Fire.

04. Hewlett Packard LaserJet 1100Xi.

05. Matrox G200 MMS.

How do I print 01 on Bug's Life product info page?.

Thanks for any assistance..

Comments (13)

Good question... I dunno what is the answer. I'll do some Googling and get back to you if I bump into an anything. You should email the people at iPage as they probably can help you..

Comment #1

Thanks oldmoney for the fast reply.

To pull down the ranking number from products database sounds pretty straight-forward to me..

But first I need to know how to sort the ranking then enter the information into the database..

Is it possible to use the ranking information already present in the admin/stats_products_purchased.php? If so, how?..

Comment #2

Is this not the function of the infobox "best_sellers.php" ?

Comment #3

1. create a new field in products DB called products_sales_rank.

2. execute this code via a cron or some other process that runs regularly to update the sales rank data... you do NOT want to run this every time the product info page is pulled.

$sql_query = tep_db_query("select distinct products_id from "TABLE_PRODUCTS" where products_status = '1' order by products_ordered desc";.

$sales_rank = 0;.

While ($best_sellers = tep_db_fetch_array($sql_query)) {.

        tep_db_query("update "TABLE_PRODUCTS" set products_sales_rank = ".++$sales_rank." where products_id = "$best_sellers['products_id']);.

}.

That's pretty much it. If I were to write this up as a mod, you'd want to make appropriate changes to the admin interface to access this new field, plus create the file that includes the code above. Oh, and also I'd ditch the existing best_sellers box and use this data instead...

Comment #4

It is... but the point isn't to see the top 10 or even 20. It's to see that product Super Widget is ranked 2037...

Comment #5

One logic flaw in the above... an existing product that's status was 1 and then becomes 0 will retain it's sales rank. If you want to rank products regardless of status, don't include.

Where products_status = '1'.

Above..

Otherwise, you'll need to reset the sales_rank for products that are status 0 with the following code. Just place it below the code above..

$sql_query = tep_db_query("select distinct products_id from "TABLE_PRODUCTS" where products_status = '0'";.

While ($best_sellers = tep_db_fetch_array($sql_query)) {.

Tep_db_query("update "TABLE_PRODUCTS" set products_sales_rank = NULL where products_id = "$best_sellers['products_id']);.

}.

This post has been edited by.

Oldmoney.

: 08 May 2004, 08:53..

Comment #6

Sorry, but when I insert the code I get a parse error or Fatal error: Call to undefined function: tep_db_query().

How do I insert the code into php and execute the code?..

Comment #7

See... now you've got me writing out all the mod directions..

Try putting.

Require('includes/application_top.php');.

At the beginning. That will pull in all the required functions. This assumes the new sales_rank.php file is in catalog/admin/ (or whatever you've called it)...

Comment #8

It's in admin folder and I've insert "require('includes/application_top.php');" but I'm getting :.

Parse error: parse error, unexpected ';'.

<html>.

<?php.

Require('includes/application_top.php');.

$sql_query = tep_db_query("select distinct products_id from "TABLE_PRODUCTS" where products_status = '0'";.

While ($best_sellers = tep_db_fetch_array($sql_query)) {.

Tep_db_query("update "TABLE_PRODUCTS" set products_sales_rank = NULL where products_id = "$best_sellers['products_id']); }.

?>.

</html>..

Comment #9

Yay! It works.

After studying your code, I found a tiny mistake..

You forgot to end with a ")".

$sql_query = tep_db_query("select distinct products_id from "TABLE_PRODUCTS" where products_status = '1' order by products_ordered desc";.

Thanks very much for all your help..

Comment #10

Glad you got it working...!.

I've got an improved version I'll release as a mod this weekend. Right now, the toggles are:.

+ base ranking on order count or order count * price (approximate sales).

+ use rank order or absolute position counting.

+ include or exclude status=0 products in ranking..

Comment #11

To get the sales rank there is no need to select all products and then update the sales rank column in the products table..

Even with 100k products this will bog down the server if not done in batch updates...

Comment #12

Uh, yeah... based on your past posts, I'd guess your suggestion would be to run this process on it's own dedicated server. You want to make this into a multi-threaded app with full transactional support? Be my guest.....

Comment #13

Nah, any dodgy shared server can run this single select for a sales ranking..

Of course, been there and done that..

Running on innodb before you even joined this forum..

Comment #14


This question was taken from a support group/message board and re-posted here so others can learn from it.