holy shit

寺夺喜从天降

畅销商品模块(修改)

<?php
/**
 * best_sellers modules
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: best_sellers.php 2718 2005-12-28 06:42:39Z drbyte $
 */

if (isset($current_category_id) && ($current_category_id > 0)) {
	$best_sellers_query = "select distinct p.products_id, p.products_image, pd.products_name, p.products_ordered
                             from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, "
	. TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c
                             where p.products_status = '1'
                             and p.products_ordered > 0
                             and p.products_id = pd.products_id
                             and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                             and p.products_id = p2c.products_id
                             and p2c.categories_id = c.categories_id
                             and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id)
                             order by p.products_ordered desc, pd.products_name
                             limit " . MAX_DISPLAY_BESTSELLERS;

	$best_sellers = $db->Execute($best_sellers_query);

} else {
	$best_sellers_query = "select distinct p.products_id, pd.products_name, p.products_ordered
                             from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                             where p.products_status = '1'
                             and p.products_ordered > 0
                             and p.products_id = pd.products_id
                             and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                             order by p.products_ordered desc, pd.products_name
                             limit " . MAX_DISPLAY_BESTSELLERS;

	$best_sellers = $db->Execute($best_sellers_query);
}

if ($best_sellers->RecordCount() >= MIN_DISPLAY_BESTSELLERS) {
	$top_name =  BOX_HEADING_BESTSELLERS;
	$content_list = array();
	$rows = 0;
	while (!$best_sellers->EOF) {
		$rows++;
		$content_list[$rows]['href'] = zen_href_link(zen_get_info_page($best_sellers->fields['products_id']), 'products_id=' . $best_sellers->fields['products_id']);
		$content_list[$rows]['img'] = zen_image(DIR_WS_IMAGES . $best_sellers->fields['products_image'], $best_sellers->fields['products_name']);
		$content_list[$rows]['name']  = $best_sellers->fields['products_name'];
		//$content_list[$rows]['name'] = zen_trunc_string($best_sellers->fields['products_name'], BEST_SELLERS_TRUNCATE, BEST_SELLERS_TRUNCATE_MORE);
		$content_list[$rows]['price'] = zen_get_products_display_price2($best_sellers->fields['products_id']);
		$best_sellers->MoveNext();
	}
}

?>

posted @ 2011-04-18 17:34  潜水鱼  阅读(224)  评论(0编辑  收藏  举报

holy shit on foot