65 lines
2.6 KiB
PHP
65 lines
2.6 KiB
PHP
<?php
|
|
/*
|
|
+--------------------------------------------------------------------------
|
|
| CubeCart 4
|
|
| ========================================
|
|
| CubeCart is a registered trade mark of Devellion Limited
|
|
| Copyright Devellion Limited 2006. All rights reserved.
|
|
| Devellion Limited,
|
|
| 5 Bridge Street,
|
|
| Bishops Stortford,
|
|
| HERTFORDSHIRE.
|
|
| CM23 2JU
|
|
| UNITED KINGDOM
|
|
| http://www.devellion.com
|
|
| UK Private Limited Company No. 5323904
|
|
| ========================================
|
|
| Web: http://www.cubecart.com
|
|
| Email: info (at) cubecart (dot) com
|
|
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
|
|
| Licence Info: http://www.cubecart.com/site/faq/license.php
|
|
+--------------------------------------------------------------------------
|
|
| popularProducts.inc.php
|
|
| ========================================
|
|
| Display the most Popular Products
|
|
+--------------------------------------------------------------------------
|
|
*/
|
|
|
|
if (!defined('CC_INI_SET')) die("Access Denied");
|
|
|
|
## include lang file
|
|
$lang = getLang("includes".CC_DS."boxes".CC_DS."popularProducts.inc.php");
|
|
|
|
## query database
|
|
if ($config['pop_products_source'] == true) {
|
|
## inner join on inventory table to make sure the product exists still
|
|
$cache = new cache('boxes.popularProds');
|
|
$popularProds = $cache->readCache();
|
|
|
|
if (!$cache->cacheStatus) {
|
|
$popularProds = $db->select("SELECT I.name, I.productId , COUNT(I.productId) AS total FROM ".$glob['dbprefix']."CubeCart_order_inv AS O INNER JOIN ".$glob['dbprefix']."CubeCart_inventory AS I ON O.productId = I.productId WHERE I.disabled != '1' AND I.cat_id > 0 GROUP BY I.name DESC ORDER BY total DESC", $config['noPopularBoxItems']);
|
|
$cache->writeCache($popularProds);
|
|
}
|
|
} else {
|
|
## we wont cache this as it changes too quickly
|
|
$popularProds = $db->select("SELECT name, productId FROM ".$glob['dbprefix']."CubeCart_inventory WHERE cat_id > 0 AND disabled != '1' ORDER BY popularity DESC",$config['noPopularBoxItems']);
|
|
}
|
|
|
|
$box_content = new XTemplate("boxes".CC_DS."popularProducts.tpl");
|
|
|
|
$box_content->assign("LANG_POPULAR_PRODUCTS_TITLE", $lang['popularProducts']['popular_products']);
|
|
|
|
if ($popularProds){
|
|
for ($i=0; $i<count($popularProds); $i++) {
|
|
if (($val = prodAltLang($popularProds[$i]['productId'])) == true){
|
|
$popularProds[$i]['name'] = $val['name'];
|
|
}
|
|
$popularProds[$i]['name'] = validHTML($popularProds[$i]['name']);
|
|
$box_content->assign("DATA",$popularProds[$i]);
|
|
$box_content->parse("popular_products.li");
|
|
}
|
|
}
|
|
|
|
$box_content->parse("popular_products");
|
|
$box_content = $box_content->text("popular_products");
|
|
?>
|