
09-29-2011, 11:17 AM
|
|
|
|
 eXpert
|
|
Join Date: Jun 2006
Location: New York, USA
Posts: 389
|
|
|
Re: Bestsellers without Advanced Statistics (4.4.3 Gold)
Quote:
Originally Posted by IPR
Jillsbyte, thank you for a great and simple alteration to the module. Would it be possible to make it show up in two seperate time frames? For example, if I wanted one block that shows "What's hot!!" that shows the sales for the last 10 days, and another block that is "All Time Favorites" that show the top ten products for the last two years?
|
OK, this is off the top of my head and I have NOT tested it, but here goes:
You would need two more variables in the top section. All order dates should be greater than 0 since they're Unix timestamps:
Code:
$search_query_all = '';
Code:
$bs_sale_cutoff_all = 0;
After this line:
Code:
$search_query = " AND $sql_tbl[products_categories].categoryid IN ('" . implode("','", $cat_ids) . "')";
add:
Code:
$search_query_all = $search_query;
This will allow your all-time search query to also capture category-specific products.
Then you would need to run a different query and search of the bestsellers to capture the all-time bestsellers (using the $bs_sale_cutoff_all rather than $bs_sale_cutoff that is used in the date-limited query):
Code:
$salesprod_data_all = func_query_hash("SELECT $sql_tbl[order_details].productid, SUM($sql_tbl[order_details].amount) AS number FROM $sql_tbl[products] INNER JOIN ($sql_tbl[orders] INNER JOIN $sql_tbl[order_details] ON $sql_tbl[orders].orderid=$sql_tbl[order_details].orderid) ON $sql_tbl[products].productid=$sql_tbl[order_details].productid WHERE ((($sql_tbl[orders].status) IN ('C', 'P')) AND (($sql_tbl[orders].date)>= '" . $bs_sale_cutoff_all . "') AND (($sql_tbl[products].forsale)='Y')) GROUP BY $sql_tbl[order_details].productid ORDER BY number DESC, $sql_tbl[orders].date DESC, $sql_tbl[products].add_date DESC LIMIT " . $config['Bestsellers']['number_of_bestsellers']);
Code:
$salesprod_all_ids = array();
if (
is_array($salesprod_data_all)
&& !empty($salesprod_data_all)
) {
$salesprod_all_ids = array_keys($salesprod_data_all);
}
$search_query_all .= " AND $sql_tbl[products].productid IN ('" . implode("','", $salesprod_all_ids) . "')";
unset($salesprod_data_all);
$bestsellers_all = func_search_products(
$search_query_all,
@$user_account['membershipid'],
"$sql_tbl[products].product"
);
$smarty->assign_by_ref('bestsellers_all', $bestsellers_all);
You will also need to duplicate the code in bestsellers.tpl, substituting $bestsellers_all for $bestsellers. This additional code assumes you will use the same number of all-time bestsellers as for date-limited bestsellers.
Again, I haven't tested this so I'm not making any promises.
__________________
X-Cart Gold 4.1.8 (Live)
BCSE Shipping Estimator for FLC Mod
BCSE Shipping Methods per Product Mod
BCSE Customer Review Management Mod
BCSE Catalog Order Form Mod
X-Cart Gold 4.5.2 (Building/Testing)
USA
|
|