有朋友曾经问我这样的问题% }6 e% a3 s, Z
“为了方便浏览,我想在ECSHOP后台的商品列表中也显示商品的品牌”。+ N2 K: P& T* g/ A! q
下面就来讲一下如何来修改。此方法只保证在ECSHOP2.7.2版本下有效,其他版本请参照修改。
: c4 @: m# _0 X" L2 f- z
4 z6 b6 K; {3 f. b第一步:
4 h# D5 x ^1 k- P; M, j O! I/ r. K$ {首先我们来打开程序文件: /admin/includes/lib_goods.php
9 u9 c& t" |% ]2 l1 i/ z* \5 |# ]2 Q/ Y, ~& o: W3 Y# C) n2 D. I
定位到 goods_list 函数部分, K3 N& L3 D) F( l. E2 j
0 g7 u6 |* l4 ]/ G找到下面代码(大概在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, " .
2 X* `3 A, ]2 ?* Q# v o: \* F " (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ".
" W$ P. O' n# F0 N4 C " FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .5 {! `5 {6 e. s* n$ X) Q7 _& C
" ORDER BY $filter[sort_by] $filter[sort_order] ".
' }6 J5 Q! d$ d3 W! i " LIMIT " . $filter['start'] . ",$filter[page_size]"; | ( _3 a% N1 F l& c9 W
将它修改为. W! s7 ^) j$ B8 `) S3 I; u
7 \0 w+ p/ S% E! s4 V5 S
o3 \( h5 r Q# Q
8 a$ v8 F+ ~6 ^% x
第二步:
" ]9 U0 P( I% @2 C. b8 i+ ]( ?, F
, O- n+ h }1 r$ w8 j( o5 h( }. v修改 admin/templates/goods_list.htm 文件9 m) s7 V2 w7 M% W5 V, R$ ~
( I$ v. I: W/ d4 b5 w& ~1 R
找到: Z+ M. i& ?' A$ A& u: }2 K& S! @
' M* j# L; S& F& Z0 E) u{$goods.goods_name|escape:html}
( {# G# w' U. R) y2 x/ v7 Q
2 u) A* h$ K7 d在它后面增加一行代码:6 y/ _9 c! S4 C$ P1 h$ C6 ?
X/ m& w/ n& O(品牌:{$goods.brand_name})
. `* `/ I$ m' W* n( I
3 z' u6 G/ Z+ l修改到这里,你会发现品牌是能显示出来了,但是搜索功能里的按品牌搜索却失效了。别着急,第三步就是来解决这个问题的。; h5 C6 G2 c. c, @0 p( Z% U! p
( g w3 ?. [/ i9 Q2 c8 T$ `第三步(很重要):; g" Z/ J4 q5 x; n: @: D7 P
! |. f% ~; t" A/ h. H$ u- d, _" l向上,找到下面代码(大概在865行左右)4 }" T, \/ v. y8 W& X3 P+ M
4 O% L" }. z) X$ l: h$where .= " AND brand_id='$filter[brand_id]'";
2 h: ~$ D) P, U- y8 V% c7 }- o
; S N. V5 R! M6 e% D% y( C r将它修改为1 D4 Y8 ]$ }" p3 w
3 W' o1 C. I4 @! m3 G6 t
$where .= " AND g.brand_id='$filter[brand_id]'";
9 g2 Y# |9 R/ G |