ecshop获取全部商品

ecshop获取全部商品,第1张

修改一个categoryphp,把条件cat_id去掉,既 把:

/ 获得请求的分类 ID /

if (isset($_REQUEST['id']))

{

$cat_id = intval($_REQUEST['id']);

}

elseif (isset($_REQUEST['category']))

{

$cat_id = intval($_REQUEST['category']);

}

else

{

/ 如果分类ID为0,则返回首页 /

ecs_header("Location: /\n");

exit;

}

改成

/ 获得请求的分类 ID /

if (isset($_REQUEST['id']))

{

$cat_id = intval($_REQUEST['id']);

}

elseif (isset($_REQUEST['category']))

{

$cat_id = intval($_REQUEST['category']);

}

else

{

$cat_id = 0;

}

就可以了

1,打开indexphp  在最上面加

/

 获得cat_id精品列表。

 @access  private

 @param   integer

 @return  array

/

function index_get_cat_id_goods_best_list($cat_id, $num)

{

    $sql = 'Select ggoods_id, ggoods_name, ggoods_name_style, gmarket_price, gshop_price, gpromote_price, ' 

                "promote_start_date, promote_end_date, ggoods_brief, ggoods_thumb, goods_img, " 

                "gis_best, gis_new, gis_hot, gis_promote " 

            'FROM '  $GLOBALS['ecs']->table('goods')  ' AS g ' 

            "Where gis_on_sale = 1 AND gis_alone_sale = 1 AND gis_delete = 0 AND gis_best = 1 AND ("  $cat_id  " OR "  get_extension_goods($cat_id) ")";

$cats = get_children($cat_id);

$where = !empty($cats)  "AND ($cats OR "  get_extension_goods($cats)  ") " : '';

$sql =$where" 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,$smarty->assign('auction_list',    index_get_auction());        // 拍卖活动下面加

$smarty->assign('cat_id22_best_goods', index_get_cat_id_goods_best_list(22,8));

注意这里的22是分类id,8是数量

3,模板部分

<!-- {foreach  from=$cat_id29_best_goods item=goods  name=no}-->

<div class="line">

<div class="item">

<span class="no">{$smartyforeachnoiteration}</span>

    <p class="pic"><a href="{$goodsurl}"><img  src="{$goodsthumb}" alt="{$goodsname|escape:html}" class="B_blue" /></a></p>

    <p class="name">  <a href="{$goodsurl}" title="{$goodsname|escape:html}">{$goodsname|escape}</a></p>

    <p class="price">

    <span class="goodsPrice"> 

    <!-- {if $goodspromote_price neq ""} -->

    {$goodspromote_price}

    <!-- {else}-->

    {$goodsshop_price}

    <!--{/if}-->

    </span>

    </p>

</div>

</div>

<div style="clear:both"></div>        

<!-- {/foreach} -->

以上就是关于ecshop获取全部商品全部的内容,包括:ecshop获取全部商品、ECSHOP动态获取分类下的商品、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9287237.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-26
下一篇2023-04-26

发表评论

登录后才能评论

评论列表(0条)

    保存