关于在商品详情页面显示同一品牌的商品列表 的解决方式

2016-07-07 15:04 来源:www.chinab4c.com 作者:ecshop专家

[url=http://bbs.ecshop.com/thread-95640-1-1.html]http://bbs.ecshop.com/thread-95640-1-1.html
这个帖子的解决方法
是个笨方法来的,但总归是有点用
/**
* 获得指定商品id的同品牌商品
*
* @paraminteger$goods_id
* @paramarray $attr
*
* @returnvoid
*/
function get_brand_goodslist($goods_id)
{
$brand_id=$GLOBALS['db']->getOne("select brand_id from ".
$GLOBALS['ecs']->table('goods') . " where goods_id=$goods_id");
$sql=" select * from ". $GLOBALS['ecs']->table('goods').
" where brand_id in($brand_id) limit 5";
$res = $GLOBALS['db']->query($sql);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
$arr[$row['goods_id']]['goods_id']= $row['goods_id'];
$arr[$row['goods_id']]['goods_name']= $row['goods_name'];
$arr[$row['goods_id']]['short_name']= $GLOBALS['_CFG']['goods_name_length'] > 0 ?
sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$arr[$row['goods_id']]['goods_thumb']= get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price']= price_format($row['shop_price']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
if ($row['promote_price'] > 0)
{
$arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']);
}
else
{
$arr[$row['goods_id']]['promote_price'] = 0;
}
}
return $arr;
}

在goods.php 中加这样一个方法,然后调用就可以啦~~~
大家多提意见哦~~~

[/url]

回答:
支持一个!

支持一下, 很好的功能, 收藏了

請問版主大大,該如何"調用"呢??

很好,支持