[Svn-src-all:1299] [version-2_5-dev 20188] #986 リファクタリング
yomoro
admin @ mail.ec-cube.net
2011年 2月 18日 (金) 09:47:45 JST
Subversion committed to /home/svn/open 20188
http://svn.ec-cube.net/open_trac/changeset/20188
┌────────────────────────────┐
│更新者 : yomoro │
│更新日時: 2011-02-18 09:47:45 +0900 (金, 18 2月 2011)│
└────────────────────────────┘
Log:
--------------------------------------------------------
#986 リファクタリング
Changed: [U:修正,A:追加,D:削除]
--------------------------------------------------------
U branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Best5.php
変更: branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Best5.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Best5.php 2011-02-17 22:55:52 UTC (rev 20187)
+++ branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Best5.php 2011-02-18 00:47:45 UTC (rev 20188)
@@ -90,7 +90,6 @@
$objQuery = SC_Query::getSingletonInstance();
$sql = '';
$sql .= ' SELECT';
- $sql .= ' DISTINCT';
$sql .= ' T1.best_id,';
$sql .= ' T1.category_id,';
$sql .= ' T1.rank,';
@@ -108,14 +107,26 @@
$arrBestProducts = $objQuery->getAll($sql);
// 各商品の詳細情報を取得
$objQuery = SC_Query::getSingletonInstance();
- $arrProduct = array();
$objProduct = new SC_Product();
+ // where条件生成&セット
+ $arrBestProductIds = array();
+ $where = 'product_id IN ( ';
foreach( $arrBestProducts as $key => $val ) {
- $where = 'product_id = ' . $val['product_id'];
- $objQuery->setWhere($where);
- $arrProductLsit = $objProduct->lists($objQuery);
- if ( !empty($arrProductLsit) ) {
- $arrProduct[$key] = array_merge($val, $arrProductLsit[0]);
+ $arrBestProductIds[] = $val['product_id'];
+ }
+ $where .= implode(', ', $arrBestProductIds);
+ $where .= ' )';
+ $objQuery->setWhere($where);
+ // 取得
+ $arrProductList = $objProduct->lists($objQuery);
+ // おすすめ商品情報とマージ
+ $arrProduct = array();
+ 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;
Svn-src-all メーリングリストの案内