VCPHP网站模板 - 外贸网站建设,外贸网站模板

VCPHP网站模板

当前位置: 首页 > ZenCart > ZenCart教程 >

ZenCart首页指定显示某个分类下面的产品

时间:2013-12-28 23:37来源:未知 作者:admin 点击:
ZenCartt默认情况下首页显示的新进产品是随机获取所有最近添加的产品。有时候不想在所有的分类里面获取这些最新产品,而是指定在某些分类下面。分享一下这个修改方法。 首先打开include

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

首先打开includesmodulesnew_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语句后面
}
}

(责任编辑:VCPHP网站模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
验证码: 点击我更换图片
栏目列表
推荐内容
 
QQ在线咨询
售前电话热线
400-083-8184
售前QQ客服