ecshop中如何在分类列表中调用商品同一级分类的名称
1个回答
展开全部
在category.php中的category_get_goods函数的
/* 获得商品列表 */
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, title_adwords, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img, g.click_count as click_count ';
$sql .= $sort =='sale_number'? ', SUM(og.goods_number) as sale_number ':'';
$sql .='FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " ;
改成
/* 获得商品列表 */
$sql = 'SELECT g.goods_id, g.cat_id,c.cat_name, g.goods_name, g.goods_name_style, title_adwords, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img, g.click_count as click_count ';
$sql .= $sort =='sale_number'? ', SUM(og.goods_number) as sale_number ':'';
$sql .='FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
'LEFT JOIN ' . $GLOBALS['ecs']->table(category') . ' AS c on c.cat_id =g.cat_id ' ;
在
$arr[$row['goods_id']]['name'] = $row['goods_name'];
下面增加
$arr[$row['goods_id']]['cat_name'] = $row['cat_name'];
然后在模板里就可以在模板中通过{goods.cat_name}直接调用
/* 获得商品列表 */
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, title_adwords, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img, g.click_count as click_count ';
$sql .= $sort =='sale_number'? ', SUM(og.goods_number) as sale_number ':'';
$sql .='FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " ;
改成
/* 获得商品列表 */
$sql = 'SELECT g.goods_id, g.cat_id,c.cat_name, g.goods_name, g.goods_name_style, title_adwords, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img, g.click_count as click_count ';
$sql .= $sort =='sale_number'? ', SUM(og.goods_number) as sale_number ':'';
$sql .='FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
'LEFT JOIN ' . $GLOBALS['ecs']->table(category') . ' AS c on c.cat_id =g.cat_id ' ;
在
$arr[$row['goods_id']]['name'] = $row['goods_name'];
下面增加
$arr[$row['goods_id']]['cat_name'] = $row['cat_name'];
然后在模板里就可以在模板中通过{goods.cat_name}直接调用
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询