永发信息网

ecshop二次开发

答案:2  悬赏:80  手机版
解决时间 2021-11-09 03:53
  • 提问者网友:骨子里的高雅
  • 2021-11-08 10:43
ecshop二次开发
最佳答案
  • 五星知识达人网友:雪起风沙痕
  • 2021-11-08 11:28
调用分类下的商品方法:

1.
首先、我们再在/includes/lib_goods.php下增加如下代码:这个代码我加在了最底部:
function index_get_cat_id_goods_best_list($cat_id = '', $num = '') 

$sql = 'Select g.goods_id, g.cat_id,c.parent_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . 
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ". 
"promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " . 
"g.is_best, g.is_new, g.is_hot, g.is_promote " . 
'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 
'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' . 
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ". 
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ". 
"Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ". 
$sql .= " AND (c.parent_id =" . $cat_id. " OR g.cat_id = " . $cat_id ." OR g.cat_id ". db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) .")"; 
$sql .= " LIMIT $num"; 
$res = $GLOBALS['db']->getAll($sql); 
$goods = array(); 
foreach ($res AS $idx => $row) 

$goods[$idx]['id'] = $row['article_id']; 
$goods[$idx]['id'] = $row['goods_id']; 
$goods[$idx]['name'] = $row['goods_name']; 
$goods[$idx]['brief'] = $row['goods_brief']; 
$goods[$idx]['brand_name'] = $row['brand_name']; 
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']); 
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? 
sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; 
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']); 
$goods[$idx]['market_price'] = price_format($row['market_price']); 
$goods[$idx]['shop_price'] = price_format($row['shop_price']); 
$goods[$idx]['thumb'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb']; 
$goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img']; 
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); 

return $goods; 
}2.
第二、在index.php增加以下代码
$smarty->assign('cat_id16_best_goods', index_get_cat_id_goods_best_list(16,8));
其中16是你调用的分类的id,这个分类可以是一级,也可以是二级。要注意有两个16
8是你要调用的条数。
3.

第三、新增一个.lbi,添加如下代码   :我建立的名字是catec68.lib


                 
                    {$goods.short_name|truncate:8:true}
                    市场价:{$goods.market_price}元  
                    无忧康价:{$goods.shop_price}元
                    售出:{$lang.order_number}件
                    
                
    
    


第四、在首页模板index.dwt中,在你想显示的位置加上以下代码:







至于这里面的参数


这个是循环一个数组,hot_goods.是在PHP赋值到前台的数字.item是循环的一个一个对象。
name值一般的可以做一些循环次数的判断
全部回答
  • 1楼网友:归鹤鸣
  • 2021-11-08 13:01
在页面动态程序比如index.php中声明

$smarty->assign('best_goods', get_recommend_goods('best')); // 推荐商品

然后在模板中启用



只能告诉你一个思路,明白smarty模板是这样弄的就行
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯