public function getList($where = array(), $order = null, $offset = null, $limit = null) { if (empty($where['ProductFilterOption.productCategoryFilterOptionID'])) { $select = new Select(); $select->from(array('b' => 'Product')); $select->join(array('c' => 'ProductCategory'), 'b.productCategoryID = c.productCategoryID', array('categoryName')); $select->where($where); $select->offset($offset); $select->limit($limit); $select->order($order); } else { $select = $this->getSelect(); $select->columns(array())->join(array('b' => 'Product'), 'ProductFilterOption.productID = b.productID')->join(array('c' => 'ProductCategory'), 'b.productCategoryID = c.productCategoryID', array('categoryName'))->where($where)->offset($offset)->limit($limit)->group(array('ProductFilterOption.productID'))->having('count(ProductFilterOption.productID) > ' . (count($where['ProductFilterOption.productCategoryFilterOptionID']) - 1)); $select->order($order); } $paginator = $this->paginate($select); $paginator->setCurrentPageNumber(ceil($offset / $limit) + 1); //$paginator->setItemCountPerPage(1); $products = $paginator->getCurrentItems()->getArrayCopy(); $pages = $paginator->getPages(); $productsCount = $paginator->getTotalItemCount(); foreach ($products as $k => $v) { $products[$k]['leftTime'] = Utility::getLeftTime(time(), $v['endTime']); } return array('products' => $products, 'productsCount' => $productsCount, 'pages' => $pages); }
public function getProducts($where, $page = 1, $limit = 10, $order = '') { $select = $this->getSelect(); $select->join(array('b' => 'Store'), 'Product.storeID = b.storeID', array('storeName'), 'left'); $select->where($where); $select->where(array('Product.isDel' => 0)); if (!empty($order)) { $select->order($order); } else { $select->order('Product.instime DESC'); } $paginator = $this->paginate($select, $this->getSql()->getAdapter()); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($limit); $data = $paginator->getCurrentItems()->getArrayCopy(); $pages = $paginator->getPages(); $total = $paginator->getTotalItemCount(); foreach ($data as $k => $v) { $data[$k]['leftTime'] = Utility::getLeftTime(time(), $v['endTime']); } $result = array('data' => $data, 'pages' => $pages, 'total' => $total); return $result; }
public function detailAction() { $storeID = $this->queryData['storeID']; $auctionStatus = $this->queryData['auctionStatus']; $order = $this->queryData['order']; $sort = $this->queryData['sort']; $storeCategoryID = $this->queryData['storeCategoryID']; $where = array('storeID' => $storeID); $storeInfo = $this->storeModel->fetch($where); $storeCategories = $this->storeCategoryModel->select(array('storeID' => $storeID))->toArray(); /*$storeRecommendProducts = $this->productModel->getProducts(array('Product.isStoreRecommend' => 1, 'Product.storeID' => $storeID, 'Product.auctionStatus' => array(1, 2))); $storeRecommendProductsData = $storeRecommendProducts['data']; foreach($storeRecommendProductsData as $k => $v){ $storeRecommendProductsData[$k]['leftTime'] = Utility::getLeftTime(time(), $v['endTime']); }*/ if (!empty($order) && !empty($sort)) { $order = 'Product.' . $order . ' ' . $sort; } $where = new Where(); $where->equalTo('Product.storeID', $storeID); if (!empty($auctionStatus)) { $where->equalTo('Product.auctionStatus', $auctionStatus); } else { $where->in('Product.auctionStatus', array(1, 2)); } $where->isNull('Product.specialID'); if (!empty($storeCategoryID)) { $where->and->nest()->or->equalTo('Product.firstStoreCategoryID', $storeCategoryID)->or->equalTo('Product.secondStoreCategoryID', $storeCategoryID)->or->equalTo('Product.thirdStoreCategoryID', $storeCategoryID); } $storeProducts = $this->productModel->getProducts($where, $this->pageNum, $this->limit, $order); $storeProductsData = $storeProducts['data']; foreach ($storeProductsData as $k => $v) { $storeProductsData[$k]['leftTime'] = Utility::getLeftTime(time(), $v['endTime']); } $this->view->setVariables(array('storeInfo' => $storeInfo, 'storeProducts' => $storeProductsData, 'storeCategories' => $storeCategories, 'pages' => $storeProducts['pages'], 'auctionStatus' => $auctionStatus, 'order' => $this->queryData['order'], 'sort' => $sort, 'storeCategoryID' => $storeCategoryID)); return $this->view; }