第一步:
首先我們來打開程序文件: /admin/includes/lib_goods.php
定位到 goods_list 函數部分
找到下面代碼(大概在911行左右)
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
" (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ".
" FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
" ORDER BY $filter[sort_by] $filter[sort_order] ".
" LIMIT " . $filter['start'] . ",$filter[page_size]";
將它修改爲
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, g.sort_order, goods_number, integral, " .
" (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote,b.brand_name ".
" FROM " . $GLOBALS['ecs']->table('goods') . " AS g ".
"left join ".$GLOBALS['ecs']->table('brand') . " AS b on g.brand_id=b.brand_id ".
" WHERE is_delete='$is_delete' $where" .
" ORDER BY $filter[sort_by] $filter[sort_order] ".
" LIMIT " . $filter['start'] . ",$filter[page_size]";
第二步:
修改 admin/templates/goods_list.htm 文件
找到
{$goods.goods_name|escape:html}
在它後面增加一行代碼:
(品牌:{$goods.brand_name})
找到
<th><a href="javascript:listTable.sort('goods_name'); ">{$lang.goods_name}</a>{$sort_goods_name}</th>
在它後面增加一行代碼:
<th><a href="javascript:listTable.sort('brand_name'); ">{$lang.brand_name}</a>{$sort_brand_name}</th>
修改到這裏,你會發現品牌是能顯示出來了,但是搜索功能裏的按品牌搜索卻失效了。彆着急,第三步就是來解決這個問題的。
第三步(很重要):
向上,找到下面代碼(大概在865行左右)
$where .= " ANDbrand_id='$filter[brand_id]'";
將它修改爲
$where .= " AND g.brand_id='$filter[brand_id]'";