zencart首页index.php打开,zencart在首页指定新进产品显示某个分类下面的产品

zen cart默认情况下首页显示的新进产品是随机获取所有最近添加的产品。有时候不想在所有的分类里面获取这些最新产品,而是指定在某些分类下面。分享一下这个修改方法。

首先打开\includes\modules\new_products.php 这个模块文件就是首页调用的新进产品模块。要想实现这个功能,只要修改$new_products_query 这个变量,这个是查询最新产品的SQL语句。

看下面这段代码:

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′) ) {

$new_products_query = “select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,

p.products_date_added, p.products_price, p.products_type, p.master_categories_id

from ” . TABLE_PRODUCTS . ” p, ” . TABLE_PRODUCTS_DESCRIPTION . ” pd

where p.products_id = pd.products_id

and pd.language_id = ‘” . (int)$_SESSION['languages_id'] . “‘

and p.products_status = 1 ” . $display_limit;

} else {

// get all products and cPaths in this subcat tree

$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) {

// build products-list string to insert into SQL query

foreach($productsInCategory as $key => $value) {

$list_of_products .= $key . ‘, ‘;

}

$list_of_products = substr($list_of_products, 0, -2); // remove trailing comma

$new_products_query = “select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,

p.products_date_added, p.products_price, p.products_type, p.master_categories_id

from ” . TABLE_PRODUCTS . ” p, ” . TABLE_PRODUCTS_DESCRIPTION . ” pd

where p.products_id = pd.products_id

and pd.language_id = ‘” . (int)$_SESSION['languages_id'] . “‘

and p.products_status = 1

and p.products_id in (” . $list_of_products . “)”;

}

}

修改成如下:

$filter_cate=”;

$cate_IDS=”22″;///要显示的分类ID,如果有父分类,请输入子分类的ID

if($this_is_home_page){

$filter_cate=” and p.master_categories_id in($cate_IDS) “;

}

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′) ) {

$new_products_query = “select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,

p.products_date_added, p.products_price, p.products_type, p.master_categories_id

from ” . TABLE_PRODUCTS . ” p, ” . TABLE_PRODUCTS_DESCRIPTION . ” pd

where p.products_id = pd.products_id

and pd.language_id = ‘” . (int)$_SESSION['languages_id'] . “‘

and p.products_status = 1 ” . $display_limit.$filter_cate;///添加到SQL语句后面

} else {

// get all products and cPaths in this subcat tree

$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) {

// build products-list string to insert into SQL query

foreach($productsInCategory as $key => $value) {

$list_of_products .= $key . ‘, ‘;

}

$list_of_products = substr($list_of_products, 0, -2); // remove trailing comma

$new_products_query = “select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,

p.products_date_added, p.products_price, p.products_type, p.master_categories_id

from ” . TABLE_PRODUCTS . ” p, ” . TABLE_PRODUCTS_DESCRIPTION . ” pd

where p.products_id = pd.products_id

and pd.language_id = ‘” . (int)$_SESSION['languages_id'] . “‘

and p.products_status = 1

and p.products_id in (” . $list_of_products . “)”.$filter_cate;///添加到SQL语句后面

}

}

(责任编辑:最模板)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
.IMLhGedWbazen{ width:1160px;margin:0 auto;padding:0; overflow:hidden; } .lista{height:auto; display:none;} .active{ display:block;} .AiEosctbazen{ margin-left:0px; overflow: hidden; display: block;} .SNdZRbazen { overflow: hidden; display: BLOCK; width: 100%; background: #f3f3f3; } .AiEosctbazen ul{ } .AiEosctbazen ul li{list-style: none; float:left; display: inline-block; width:32%; height:36px; line-height: 36px; text-align: center; margin-left: 0px;} .AiEosctbazen ul li a{ text-decoration:none;font-size:20px; color:#333; font-weight:bold; display:block;} .AiEosctbazen ul li a:hover{ background:#eee;} .AiEosctbazen ul li a.cur{ z-index:9999; font-size:20px; color: #f65a00; font-weight: bold; background: #f3f3f3; border: 1px solid #eee; border-bottom: none;} .uaCOnerbazen {width:100%;text-align:center;margin:0 auto; } [removed] $(document).ready(function(){ var intervalID; var curLi; $(".AiEosctbazen li a").mouseover(function(){ curLi=$(this); intervalID=setInterval(onMouseOver,250); }); function onMouseOver(){ $(".active").removeClass("active"); $(".lista").eq($(".AiEosctbazen li a").index(curLi)).addClass("active"); $(".cur").removeClass("cur"); curLi.addClass("cur"); } $(".AiEosctbazen li a").mouseout(function(){ clearInterval(intervalID); }); $(".AiEosctbazen li a").click(function(){ clearInterval(intervalID); $(".active").removeClass("active"); $(".lista").eq($(".AiEosctbazen li a").index(curLi)).addClass("active"); $(".cur").removeClass("cur"); curLi.addClass("cur"); }); }); [removed] Akční zboží Nejprodávanější zboží Nejnovější zboží <?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值