function export($io = 'csv') { if ($io != 'csv') { parent::export($io); exit; } include_once 'shopObject.php'; $step = 20; $offset = 0; $dataio = $this->system->loadModel('system/dataio'); $p = $this->system->loadModel('goods/products'); $gtype = $this->system->loadModel('goods/gtype'); if (!($cols = $dataio->columns($io))) { $cols = 'goods_id,type_id,cat_id,marketable,pdt_desc,name,bn,brand,brief,intro,mktprice,price,cost,weight,unit,store,params,spec,spec_desc,image_file'; //todo ...当前列 $cols_attr = 'p_1'; for ($i = 1; $i < 29; $i++) { $cols_attr .= ',p_' . $i; } } $last_type_id = -1; $list = $this->model->getList($cols . ',' . $cols_attr, $_POST, $offset, $step, $count, array('type_id', 'asc')); while ($count > $offset) { if ($offset == 0) { $dataio->export_begin($io, null, 'goods', $count); } else { $list = $this->model->getList($cols . ',' . $cols_attr, $_POST, $offset, $step, $count, array('type_id', 'asc')); } foreach ($list as $v) { if (trim($v['bn']) == '') { continue; } if ($last_type_id != $v['type_id']) { $aGtype = $gtype->instance($v['type_id']); $keys = $p->getTypeExportTitle($aGtype); $a = array($keys); $dataio->export_rows($io, $a); unset($proto); foreach ($keys as $k1 => $v1) { $proto[$k1] = ''; } } $data = $p->getGoodsExportData($v, $proto, $aGtype['name'], unserialize($aGtype['props']), $aGtype['params']); $dataio->export_rows($io, $data); $last_type_id = $v['type_id']; } $offset += $step; } $dataio->export_finish($io); }