action(); $this->sendResponse(); } /** * Page のアクション. * * @return void */ function action() { // 基本情報を渡す $objSiteInfo = SC_Helper_DB_Ex::sfGetBasisData(); $this->arrInfo = $objSiteInfo->data; //おすすめ商品表示 $this->arrBestProducts = $this->lfGetRanking(); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } /** * おすすめ商品検索. * * @return array $arrBestProducts 検索結果配列 */ function lfGetRanking(){ $arrProduct = array(); // おすすめ商品取得 $objQuery = SC_Query_Ex::getSingletonInstance(); $col = 'best_id, best_id, category_id, rank, product_id, title, comment, create_date, update_date'; $table = 'dtb_best_products'; $where = 'del_flg = 0'; $objQuery->setOrder('rank'); $objQuery->setLimit(RECOMMEND_NUM); $arrBestProducts = $objQuery->select($col, $table, $where); if ( is_array($arrBestProducts) && count($arrBestProducts) > 0 ) { // 各商品の詳細情報を取得 $objQuery = SC_Query_Ex::getSingletonInstance(); $objProduct = new SC_Product_Ex(); // where条件生成&セット $arrBestProductIds = array(); $where = 'product_id IN ( '; foreach( $arrBestProducts as $key => $val ) { $arrBestProductIds[] = $val['product_id']; } $where .= implode(', ', $arrBestProductIds); $where .= ' )'; $objQuery->setWhere($where); // 取得 $arrProductList = $objProduct->lists($objQuery); // おすすめ商品情報とマージ foreach( $arrProductList as $pdct_key => $pdct_val ) { foreach( $arrBestProducts as $best_key => $best_val ) { if ( $pdct_val['product_id'] == $best_val['product_id'] ) { $arrProduct[$best_key] = array_merge($best_val, $pdct_val); break; } } } } return $arrProduct; } } ?>