/** * 商品列表 */ public function goods_listOp() { $model_goods = Model('goods'); $model_search = Model('search'); //查询条件 $condition = array(); if (!empty($_GET['gc_id']) && intval($_GET['gc_id']) > 0) { $condition['gc_id'] = $_GET['gc_id']; } elseif (!empty($_GET['keyword'])) { $condition['goods_name|goods_jingle'] = array('like', '%' . $_GET['keyword'] . '%'); } //所需字段 $fieldstr = "goods_id,goods_commonid,store_id,goods_name,goods_price,goods_marketprice,goods_image,goods_salenum,evaluation_good_star,evaluation_count"; // 添加3个状态字段 $fieldstr .= ',is_virtual,is_presell,is_fcode,have_gift'; //排序方式 $order = $this->_goods_list_order($_GET['key'], $_GET['order']); //优先从全文索引库里查找 list($indexer_ids, $indexer_count) = $model_search->indexerSearch($_GET, $this->page); if (is_array($indexer_ids)) { //商品主键搜索 $goods_list = $model_goods->getGoodsOnlineList(array('goods_id' => array('in', $indexer_ids)), $fieldstr, 0, $order, $this->page, null, false); //如果有商品下架等情况,则删除下架商品的搜索索引信息 if (count($goods_list) != count($indexer_ids)) { $model_search->delInvalidGoods($goods_list, $indexer_ids); } uk86_pagecmd('setEachNum', $this->page); uk86_pagecmd('setTotalNum', $indexer_count); } else { $goods_list = $model_goods->getGoodsListByColorDistinct($condition, $fieldstr, $order, $this->page); } $page_count = $model_goods->gettotalpage(); //处理商品列表(抢购、限时折扣、商品图片) $goods_list = $this->_goods_list_extend($goods_list); output_data(array('goods_list' => $goods_list), mobile_page($page_count)); }
public function buildSelectSql($options = array()) { if (is_numeric($options['page'])) { $page = uk86_pagecmd('obj'); if ($options['limit'] !== 1) { $options['limit'] = $page->uk86_getLimitStart() . "," . $page->uk86_getEachNum(); } } $sql = $this->parseSql($this->selectSql, $options); $sql .= $this->parseLock(isset($options['lock']) ? $options['lock'] : false); return $sql; }
/** * 本地化页面 */ public function local_searchOp() { Uk86Language::uk86_read('home_goods_class_index'); $this->_model_search = Model('search'); //显示左侧分类 //默认分类,从而显示相应的属性和品牌 /* $default_classid = intval($_GET['cate_id']); if (intval($_GET['cate_id']) > 0) { $goods_class_array = $this->_model_search->getLeftCategory(array($_GET['cate_id'])); } elseif ($_GET['keyword'] != '') { //从TAG中查找分类 $goods_class_array = $this->_model_search->getTagCategory($_GET['keyword']); //取出第一个分类作为默认分类,从而显示相应的属性和品牌 $default_classid = $goods_class_array[0]; $goods_class_array = $this->_model_search->getLeftCategory($goods_class_array, 1);; } Tpl::output('goods_class_array', $goods_class_array); Tpl::output('default_classid', $default_classid);*/ //优先从全文索引库里查找 //list($indexer_ids,$indexer_count) = $this->_model_search->indexerSearch($_GET,self::PAGESIZE); // // //获得经过属性过滤的商品信息 // list($goods_param, $brand_array, $attr_array, $checked_brand, $checked_attr) = $this->_model_search->getAttr($_GET, $default_classid); // Tpl::output('brand_array', $brand_array); // Tpl::output('attr_array', $attr_array); // Tpl::output('checked_brand', $checked_brand); // Tpl::output('checked_attr', $checked_attr); //处理排序 $order = 'is_own_shop desc,goods_id desc'; if (in_array($_GET['key'], array('1', '2', '3'))) { $sequence = $_GET['order'] == '1' ? 'asc' : 'desc'; $order = str_replace(array('1', '2', '3'), array('goods_salenum', 'goods_click', 'goods_promotion_price'), $_GET['key']); $order .= ' ' . $sequence; } $model_goods = Model('goods'); // 字段 $fields = "goods_id,goods_commonid,goods_name,goods_jingle,gc_id,store_id,store_name,goods_price,goods_promotion_price,goods_promotion_type,goods_marketprice,goods_storage,goods_image,goods_freight,goods_salenum,color_id,evaluation_good_star,evaluation_count,is_virtual,is_fcode,is_appoint,is_presell,have_gift"; //var_dump($indexer_ids); $condition = array(); if (is_array($indexer_ids)) { //商品主键搜索 $condition['goods_id'] = array('in', $indexer_ids); $goods_list = $model_goods->getGoodsOnlineList($condition, $fields, 0, $order, self::PAGESIZE, null, false); //如果有商品下架等情况,则删除下架商品的搜索索引信息 if (count($goods_list) != count($indexer_ids)) { $this->_model_search->delInvalidGoods($goods_list, $indexer_ids); } uk86_pagecmd('setEachNum', self::PAGESIZE); uk86_pagecmd('setTotalNum', $indexer_count); } else { //执行正常搜索 if (isset($goods_param['class'])) { $condition['gc_id_' . $goods_param['class']['depth']] = $goods_param['class']['gc_id']; } if (intval($_GET['b_id']) > 0) { $condition['brand_id'] = intval($_GET['b_id']); } if ($_GET['keyword'] != '') { $condition['goods_name|goods_jingle'] = array('like', '%' . $_GET['keyword'] . '%'); } if (intval($_GET['area_id']) > 0) { $condition['areaid_2'] = intval($_GET['area_id']); //根据城市筛选 } if ($_GET['type'] == 1) { $condition['is_own_shop'] = 1; } if ($_GET['gift'] == 1) { $condition['have_gift'] = 1; } if (isset($goods_param['goodsid_array'])) { $condition['goods_id'] = array('in', $goods_param['goodsid_array']); } // $condition['is_virtual'] = 1; //虚拟商品 $goods_list = $model_goods->getGoodsListCommon($condition, $fields, $order, self::PAGESIZE); } Tpl::output('show_page1', $model_goods->showpage(4)); //显示分页并显示风格 Tpl::output('show_page', $model_goods->showpage(5)); //显示分页并显示风格 // 商品多图 /* if (!empty($goods_list)) { $commonid_array = array(); // 商品公共id数组 $storeid_array = array(); // 店铺id数组 foreach ($goods_list as $key => $value) { $commonid_array[] = $value['goods_commonid']; $storeid_array[] = $value['store_id']; foreach ($goods_list as $k => $v){ if($v['goods_commonid'] == $value['goods_commonid'] && $v['goods_id'] != $value['goods_id']){ unset($goods_list[$key]); } } } $commonid_array = array_unique($commonid_array); $storeid_array = array_unique($storeid_array); // 商品多图 $goodsimage_more = Model('goods')->getGoodsImageList(array('goods_commonid' => array('in', $commonid_array))); // 店铺 $store_list = Model('store')->getStoreMemberIDList($storeid_array); //搜索的关键字 $search_keyword = trim($_GET['keyword']); foreach ($goods_list as $key => $value) { // 商品多图 foreach ($goodsimage_more as $v) { if ($value['goods_commonid'] == $v['goods_commonid'] && $value['store_id'] == $v['store_id'] && $value['color_id'] == $v['color_id']) { $goods_list[$key]['image'][] = $v; } } // 店铺的开店会员编号 $store_id = $value['store_id']; $goods_list[$key]['member_id'] = $store_list[$store_id]['member_id']; $goods_list[$key]['store_domain'] = $store_list[$store_id]['store_domain']; //将关键字置红 if ($search_keyword){ $goods_list[$key]['goods_name_highlight'] = str_replace($search_keyword,'<font style="color:#f00;">'.$search_keyword.'</font>',$value['goods_name']); } else { $goods_list[$key]['goods_name_highlight'] = $value['goods_name']; } } }*/ Tpl::output('goods_list', $goods_list); //向前台传递商品列表 if ($_GET['keyword'] != '') { Tpl::output('show_keyword', $_GET['keyword']); } else { Tpl::output('show_keyword', $goods_param['class']['gc_name']); } $model_goods_class = Model('goods_class'); // SEO if ($_GET['keyword'] == '') { $seo_class_name = $goods_param['class']['gc_name']; if (is_numeric($_GET['cate_id']) && empty($_GET['keyword'])) { $seo_info = $model_goods_class->getKeyWords(intval($_GET['cate_id'])); if (empty($seo_info[1])) { $seo_info[1] = C('site_name') . ' - ' . $seo_class_name; } Model('seo')->type($seo_info)->param(array('name' => $seo_class_name))->show(); } } elseif ($_GET['keyword'] != '') { Tpl::output('html_title', (empty($_GET['keyword']) ? '' : $_GET['keyword'] . ' - ') . C('site_name') . L('nc_common_search')); } // 当前位置导航 $nav_link_list = $model_goods_class->getGoodsClassNav(intval($_GET['cate_id'])); Tpl::output('nav_link_list', $nav_link_list); // 得到自定义导航信息 //$nav_id = intval($_GET['nav_id']) ? intval($_GET['nav_id']) : 0; //Tpl::output('index_sign', $nav_id); Tpl::output('index_sign', "search_local"); // 地区 $city_array = Model('area')->getServiceGoodsCity(); Tpl::output('city_array', $city_array); //var_dump($city_array); uk86_loadfunc('search'); // 浏览过的商品 $viewed_goods = Model('goods_browse')->getViewedGoodsList($_SESSION['member_id'], 20); Tpl::output('viewed_goods', $viewed_goods); Tpl::showpage('local_search'); }