当前位置: 首页>>代码示例>>PHP>>正文


PHP product_goods_attr_list函数代码示例

本文整理汇总了PHP中product_goods_attr_list函数的典型用法代码示例。如果您正苦于以下问题:PHP product_goods_attr_list函数的具体用法?PHP product_goods_attr_list怎么用?PHP product_goods_attr_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了product_goods_attr_list函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: product_list

/**
 * 获得商品的货品列表
 *
 * @access  public
 * @params  integer $goods_id
 * @params  string  $conditions
 * @return  array
 */
function product_list($goods_id, $conditions = '')
{
    /* 过滤条件 */
    $param_str = '-' . $goods_id;
    $result = get_filter($param_str);
    if ($result === false) {
        $day = getdate();
        $today = local_mktime(23, 59, 59, $day['mon'], $day['mday'], $day['year']);
        $filter['goods_id'] = $goods_id;
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        $filter['stock_warning'] = empty($_REQUEST['stock_warning']) ? 0 : intval($_REQUEST['stock_warning']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'product_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['extension_code'] = empty($_REQUEST['extension_code']) ? '' : trim($_REQUEST['extension_code']);
        $filter['page_count'] = isset($filter['page_count']) ? $filter['page_count'] : 1;
        $where = '';
        /* 库存警告 */
        if ($filter['stock_warning']) {
            $where .= ' AND goods_number <= warn_number ';
        }
        /* 关键字 */
        if (!empty($filter['keyword'])) {
            $where .= " AND (product_sn LIKE '%" . $filter['keyword'] . "%')";
        }
        $where .= $conditions;
        /* 记录总数 */
        $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('products') . " AS p WHERE goods_id = {$goods_id} {$where}";
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $sql = "SELECT product_id, goods_id, goods_attr, product_sn, product_number\n                FROM " . $GLOBALS['ecs']->table('products') . " AS g\n                WHERE goods_id = {$goods_id} {$where}\n                ORDER BY {$filter['sort_by']} {$filter['sort_order']}";
        $filter['keyword'] = stripslashes($filter['keyword']);
        //set_filter($filter, $sql, $param_str);
    } else {
        $sql = $result['sql'];
        $filter = $result['filter'];
    }
    $row = $GLOBALS['db']->getAll($sql);
    /* 处理规格属性 */
    $goods_attr = product_goods_attr_list($goods_id);
    foreach ($row as $key => $value) {
        $_goods_attr_array = explode('|', $value['goods_attr']);
        if (is_array($_goods_attr_array)) {
            $_temp = '';
            foreach ($_goods_attr_array as $_goods_attr_value) {
                $_temp[] = $goods_attr[$_goods_attr_value];
            }
            $row[$key]['goods_attr'] = $_temp;
        }
    }
    return array('product' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}
开发者ID:jz233,项目名称:TheProject,代码行数:61,代码来源:lib_goods.php

示例2: str_replace

     $goods_sns = str_replace("\n", ',', str_replace("\r", '', $_POST['sn_list']));
     $sql = "SELECT DISTINCT goods_id FROM " . $ecs->table('goods') . " WHERE goods_sn " . db_create_in($goods_sns);
     $goods_ids = join(',', $db->getCol($sql));
     $where = " WHERE goods_id " . db_create_in($goods_ids);
 }
 $sql = "SELECT DISTINCT goods_id, goods_sn, goods_name, market_price, shop_price, goods_number, integral, give_integral, brand_id, is_real FROM " . $ecs->table('goods') . $where;
 $smarty->assign('goods_list', $db->getAll($sql));
 /* 取编辑商品的货品列表 */
 $product_exists = false;
 $sql = "SELECT * FROM " . $ecs->table('products') . $where;
 $product_list = $db->getAll($sql);
 if (!empty($product_list)) {
     $product_exists = true;
     $_product_list = array();
     foreach ($product_list as $value) {
         $goods_attr = product_goods_attr_list($value['goods_id']);
         $_goods_attr_array = explode('|', $value['goods_attr']);
         if (is_array($_goods_attr_array)) {
             $_temp = '';
             foreach ($_goods_attr_array as $_goods_attr_value) {
                 $_temp[] = $goods_attr[$_goods_attr_value];
             }
             $value['goods_attr'] = implode(',', $_temp);
         }
         $_product_list[$value['goods_id']][] = $value;
     }
     $smarty->assign('product_list', $_product_list);
     //释放资源
     unset($product_list, $sql, $_product_list);
 }
 $smarty->assign('product_exists', $product_exists);
开发者ID:554119220,项目名称:kjrscrm,代码行数:31,代码来源:goods_batch.php


注:本文中的product_goods_attr_list函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。