Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Changing Bestsellers to only show last month's best sellers


Guest

Recommended Posts

I am trying to modify the bestsellers box to only show the top selling items for the last month.

 

I have modified the sql statement in boxes/bestsellers.php to the following:

 

<?php

 if ($cPath) {

   $best_sellers_query = tep_db_query("select distinct p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_ordered, o.date_purchased from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_ORDERS . " o where o.date_purchased>=now() - INTERVAL 1 MONTH and p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and (c.categories_id = '" . $current_category_id . "' OR c.parent_id = '" . $current_category_id . "') order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);

 } else {

   $best_sellers_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_ordered, o.date_purchased from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_ORDERS . " o where o.date_purchased>=now() - INTERVAL 1 MONTH and p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);

 }

 

This *should* work, yet, on the site the box just shows the best seller listed 10 times, but I can't figure out why.

 

Any ideas what I might be missing, or is this more complicated than I think :?

 

Thanks,

Ian

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...