zencart主页产品模块有3个,分别是new products,featured products ,specials products。这3个模块增加产品之后都是随机显现的,改写一次变一次,正本这么的处理方式是为了主页显现的产品过于陈旧而设置,可是实践使用傍边萝卜青菜,各有所爱,需要纷歧。而大多数的人则喜爱把最终上载的产品排在最前,这么完成起来本来也很简单。下面是修改办法。 1,首页new products的修改 打开 includes/modules/你的模板目录/new_products.php 文件,找到 if ($new_products_query != ”) $new_products = $db->ExecuteRandomMulti($new_products_query, MAX_DISPLAY_NEW_PRODUCTS); 将其修改为: if ($new_products_query != ”) $new_products = $db->Execute($new_products_query, MAX_DISPLAY_NEW_PRODUCTS); 继续查找 $new_products->MoveNextRandom(); 修改为 $new_products->MoveNext(); 2,首页featured products的修改 打开 includes/modules/你的模板目录/featured_products.php 找到 if ($featured_products_query != ”) $featured_products = $db->ExecuteRandomMulti($featured_products_query, MAX_DISPLAY_NEW_PRODUCTS); 将其修改为: if ($featured_products_query != ”) $featured_products = $db->Execute($featured_products_query, MAX_DISPLAY_NEW_PRODUCTS); 继续查找: $featured_products->MoveNextRandom(); 修改为: $featured_products->MoveNext(); 3,首页specials修改 打开 includes/modules/你的模板目录/specials_index.php 找到 if ($specials_index_query != ”) $specials_index = $db->ExecuteRandomMulti($specials_index_query, MAX_DISPLAY_NEW_PRODUCTS); 将其修改为: if ($specials_index_query != ”) $specials_index = $db->Execute($specials_index_query, MAX_DISPLAY_NEW_PRODUCTS); 继续查找: $specials_index->MoveNextRandom(); 修改为: $specials_index->MoveNext(); 上面修改完之后,这样就能把首页的3个模块固定住,只需最后一步就能将最新的排在最前面。 重点:依次在上面3个文件中搜索 p.products_status = 1 ” . $display_limit; 分别将其修改为: p.products_status = 1 ORDER BY pd.products_id DESC” ; 就完工了! 4,产品列表修改 打开后台 Configuration—Product Listing—Display Product Listing Default Sort Order 将其设为2d 然后打开文件 includes\index_filters\default_filter.php 搜索 $listing_sql .= ” order by pd.products_name ” . ($sort_order == ‘d’ ? ‘desc’ : ”); 修改成 $listing_sql .= ” order by p.products_date_added ” . ($sort_order == ‘d’ ? ‘desc’ : ”); 就可以按添加的时间排序。 注释: d就是desc即倒叙, a就是asc即正序, 数字的意思是你显示的顺序,比如你把Product Name设置为1了, 那么按名字倒叙就是1d 反之是1a 1,想要将分类的某个产品置顶 ?后台排序处填上2d,default_filter.php文件中将order by pd.products_name改为 order by p.products_sort_order就可以了。 2,想要将新进商品显示成自己固定的几个new_products.php 中 搜索 and p.products_id in (” . $list_of_products . “)”; 括号中改成(1,2,3)就可以了,里面放你固定产品的ID。
