/** * カテゴリー一覧の取得. * * @param bool $cid_to_key 配列のキーをカテゴリーIDにする場合はtrue * @param bool $reset スタティック変数をリセットする場合はtrue * @return array カテゴリー一覧の配列 */ public function getList($cid_to_key = FALSE, $reset = FALSE) { static $arrCategory = array(), $cidIsKey = array(); if ($reset) { $arrCategory = array(); $cidIsKey = array(); } if (!isset($arrCategory[$this->count_check])) { $objQuery = Application::alias('eccube.query'); $col = 'dtb_category.*, dtb_category_total_count.product_count'; $from = 'dtb_category left join dtb_category_total_count ON dtb_category.category_id = dtb_category_total_count.category_id'; // 登録商品数のチェック if ($this->count_check) { $where = 'del_flg = 0 AND product_count > 0'; } else { $where = 'del_flg = 0'; } $objQuery->setOption('ORDER BY rank DESC'); $arrTmp = $objQuery->select($col, $from, $where); $arrCategory[$this->count_check] = $arrTmp; } if ($cid_to_key) { if (!isset($cidIsKey[$this->count_check])) { // 配列のキーをカテゴリーIDに $cidIsKey[$this->count_check] = Utils::makeArrayIDToKey('category_id', $arrCategory[$this->count_check]); } return $cidIsKey[$this->count_check]; } return $arrCategory[$this->count_check]; }
/** * 商品IDを指定し、商品一覧を取得する * * Query::setOrder() や Query::setLimitOffset() を設定して, 商品一覧 * の配列を取得する. * FIXME: 呼び出し元で設定した、Query::setWhere() も有効に扱いたい。 * * @param Query $objQuery Query インスタンス * @param array $arrProductId 商品ID * @return array 商品一覧の配列 (キー: 商品ID) */ public function getListByProductIds(Query &$objQuery, $arrProductId = array()) { if (empty($arrProductId)) { return array(); } $where = 'alldtl.product_id IN (' . Utils::repeatStrWithSeparator('?', count($arrProductId)) . ')'; $where .= ' AND alldtl.del_flg = 0'; $objQuery->setWhere($where, $arrProductId); $arrProducts = $this->lists($objQuery); // 配列のキーを商品IDに $arrProducts = Utils::makeArrayIDToKey('product_id', $arrProducts); // Query::setOrder() の指定がない場合、$arrProductId で指定された商品IDの順に配列要素を並び替え if (strlen($objQuery->order) === 0) { $arrTmp = array(); foreach ($arrProductId as $product_id) { $arrTmp[$product_id] = $arrProducts[$product_id]; } $arrProducts =& $arrTmp; unset($arrTmp); } // 税込金額を設定する $this->setIncTaxToProducts($arrProducts); return $arrProducts; }