holy shit

寺夺喜从天降

特价商品模块(修改)

<?php
/**
 * special_products module
 * @package modules
 * @copyright
 * @license
 * @version
 */
if (!defined('IS_ADMIN_FLAG')) {
	die('Illegal Access');
}

$categories_products_id_list = '';
$list_of_products = '';
$specials_index_query = '';
$display_limit = '';

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
	$specials_index_query = "select p.products_id, p.products_image, pd.products_name, p.master_categories_id
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                           where p.products_id = s.products_id
                           and p.products_id = pd.products_id
                           and p.products_status = '1' and s.status = 1
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
} else {
	$productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);

	if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
		foreach($productsInCategory as $key => $value) {
			$list_of_products .= $key . ', ';
		}
		$list_of_products = substr($list_of_products, 0, -2); 
		$specials_index_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id
                             from (" . TABLE_PRODUCTS . " p
                             left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id
                             left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                             where p.products_id = s.products_id
                             and p.products_id = pd.products_id
                             and p.products_status = '1' and s.status = '1'
                             and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                             and p.products_id in (" . $list_of_products . ")";
	}
}

if ($specials_index_query != ''){
	$specials_index = $db->ExecuteRandomMulti($specials_index_query, MAX_DISPLAY_SPECIAL_PRODUCTS_INDEX);
}

	$row = 0;
	$content_list = array();
	$top_name = '';
	$num_products_count = ($specials_index_query == '') ? 0 : $specials_index->RecordCount();

	if ($num_products_count > 0) {
		while (!$specials_index->EOF) {
			$row++;
			$products_price = zen_get_products_display_price2($specials_index->fields['products_id']);
			if (!isset($productsInCategory[$specials_index->fields['products_id']]))
				$productsInCategory[$specials_index->fields['products_id']] = zen_get_generated_category_path_rev($specials_index->fields['master_categories_id']);
			$specials_index->fields['products_name'] = zen_get_products_name($specials_index->fields['products_id']);
			
			$content_list[$row]['href'] = zen_href_link(zen_get_info_page($specials_index->fields['products_id']), 'cPath=' . $productsInCategory[$specials_index->fields['products_id']] . '&products_id=' . (int)$specials_index->fields['products_id']);
			$content_list[$row]['img'] = zen_image(DIR_WS_IMAGES . $specials_index->fields['products_image'], $specials_index->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
			$content_list[$row]['name'] = $specials_index->fields['products_name'];
			$content_list[$row]['price'] = $products_price;
			
			$specials_index->MoveNextRandom();
		}
			$top_name = sprintf(TABLE_HEADING_SPECIALS_INDEX, strftime('%B')) ;
	}
?>

posted @ 2011-04-19 11:40  潜水鱼  阅读(232)  评论(0编辑  收藏  举报

holy shit on foot