ecshop获取所有促销商品

lib_goods.php->function get_promote_goods(){}

/**
 * 获得促销商品
 *
 * @access  public
 * @return  array
 */
function get_promote_goods($cats = ‘‘)
{
    $time = gmtime();
    $order_type = $GLOBALS[‘_CFG‘][‘recommend_order‘];

    /* 取得促销lbi的数量限制 */
    $num = get_library_number("recommend_promotion");
    $sql = ‘SELECT g.grab_img,g.goods_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, b.brand_name, " .
                "g.is_best, g.is_new, g.is_hot, g.is_promote, RAND() AS rnd " .
            ‘FROM ‘ . $GLOBALS[‘ecs‘]->table(‘goods‘) . ‘ AS g ‘ .
            ‘LEFT JOIN ‘ . $GLOBALS[‘ecs‘]->table(‘brand‘) . ‘ AS b ON b.brand_id = g.brand_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 ‘ .
            " AND g.is_promote = 1 AND promote_start_date <= ‘$time‘ AND promote_end_date >= ‘$time‘ ";
    $sql .= $order_type == 0 ? ‘ ORDER BY g.sort_order, g.last_update DESC‘ : ‘ ORDER BY rnd‘;
    $sql .= " LIMIT $num ";
    $result = $GLOBALS[‘db‘]->getAll($sql);

    $goods = array();
    foreach ($result AS $idx => $row)
    {
        if ($row[‘promote_price‘] > 0)
        {
            $promote_price = bargain_price($row[‘promote_price‘], $row[‘promote_start_date‘], $row[‘promote_end_date‘]);
            $goods[$idx][‘promote_price‘] = $promote_price > 0 ? price_format($promote_price) : ‘‘;
        }
        else
        {
            $goods[$idx][‘promote_price‘] = ‘‘;
        }

        $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‘]        = get_image_path($row[‘goods_id‘], $row[‘goods_thumb‘], true);
        $goods[$idx][‘goods_img‘]    = get_image_path($row[‘goods_id‘], $row[‘goods_img‘]);
        $goods[$idx][‘url‘]          = build_uri(‘goods‘, array(‘gid‘ => $row[‘goods_id‘]), $row[‘goods_name‘]);
        //$goods[$idx][‘promote_price‘] = price_format($row[‘promote_price‘]);
        $goods[$idx][‘grab_img‘] = get_image_path2($row[‘grab_img‘]);
    }

    return $goods;
}
时间: 2024-10-08 07:20:29

ecshop获取所有促销商品的相关文章

ecshop获取促销商品总数

促销商品总数 // 促销商品总算 function grab_promote_goods_count(){ $time = gmtime(); $sql = "SELECT COUNT(*) " . "FROM " . $GLOBALS['ecs']->table('goods')."WHERE is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 AND is_promote = 1 AND

ecshop 获取某个商品的 所有订单信息 或者销量

把一下代码放到 lib_main.php /*获取有效订单信息*/ function sales_goods_order($goods_id){ $sql = 'select order_id from ' . $GLOBALS['ecs']->table('order_goods').'where goods_id='.$goods_id; /*order_goods 提取order_id*/ $res = $GLOBALS['db']->getAll($sql); foreach($res

ecshop获取浏览器各个版本

<?php /** * 获得浏览器名称和版本 * * @access public * @return string */ function get_user_browser() { if (empty($_SERVER['HTTP_USER_AGENT'])) { return ''; } $agent = $_SERVER['HTTP_USER_AGENT']; $browser = ''; $browser_ver = ''; if (preg_match('/MSIE\s([^\s|;]

ecshop获取客户端操作系统

<?php /** * 获得客户端的操作系统 * * @access private * @return void */ function get_os() { if (empty($_SERVER['HTTP_USER_AGENT'])) { return 'Unknown'; } $agent = strtolower($_SERVER['HTTP_USER_AGENT']); $os = ''; if (strpos($agent, 'win') !== false) { if (strp

转:ecshop商品分类页获取相册列表方法

ecshop商品分类页获取相册列表方法 很久之前就看到过你好在商品列表页有获取到相册列表,但是一直没有实践过,感觉应该挺简单的吧,但是最近手上的项目刚好就需要这个功能,然后就想到网上查下资料,至少找个思路就好办了,可是百度谷歌,居然没有找到任何答案.只是在百度知道看到有人提过这个问题,居然没有答案! 搜索这个线索断了,我们还有B计划,就是自己开发,哈哈.网上有人问过这个问题,但是回答的人就是说要二次开发啊什么的,当然,你好默认的功能没那么完善,需要我们进一步修改一下下,但是二次开发也不是说真的这

ECSHOP在商品详细页面上获取该商品的顶级分类id和名称

在 goods.php 文件, 找到 $smarty->assign('goods', $goods); 在它上面增加下面代码: 方法一: $cat_arr = get_parent_cats($goods['cat_id']); foreach ($cat_arr AS $val) { $goods['topcat_id']=$val['cat_id']; $goods['topcat_name']=$val['cat_name']; } 方法二: $cat_arr = get_parent_

在ECSHOP首页今日特价(促销商品)增加倒计时效果

看到不少朋友在找首页特价商品倒计时的修改方法,写了这篇文章希望能帮到有此需要的朋友们 1.首先修改程序部分 打开includes/lib_goods.php 找到get_promote_goods()函数部分 在 $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); (注:这里一定要谨慎,一定要找准位置,很多同志都是绊倒在这里的,如果你没修改过这个文件的话,大

ecshop商品分类页获取相册列表方法

第1步:找到根目录的category.php文件,查找约:486行左右(注意这不是准确位置,看实际的哦),找到这个函数: /** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order) ……以下代码省略. 然后在这个函

ecshop中index.dwt文件分析

对于ecshop新手来说,这篇总结值得关注. 对于没有web编程基础的同学来说,ecshop模板里面有两个文件特别重要, 但是这两个文件同时也很不好理解,分别是index.dwt和style.css. 而且网络上很难找到这两个文件的详细说明,经过好多天摸索,把我的经验和认识记录下来, 不一定完全正确,希望更有经验的同学能出来指导. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/