Ignore:
Timestamp:
2011/11/10 23:40:41 (12 years ago)
Author:
Seasoft
Message:

#1528 (SC_Product#getListByProductIds 第2引数の順に並び替えてから返す)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_11-dev/data/class/SC_Product.php

    r21321 r21325  
    180180     * @param SC_Query $objQuery SC_Query インスタンス 
    181181     * @param array|int $arrProductId 商品ID 
    182      * @return array 商品一覧の配列 
     182     * @return array 商品一覧の配列 (キー: 商品ID) 
    183183     */ 
    184184    function getListByProductIds(&$objQuery, $arrProductId = array()) { 
     
    191191 
    192192        $objQuery->setWhere($where, $arrProductId); 
    193         $arrRet = $this->lists($objQuery); 
    194         return $arrRet; 
     193        $arrProducts = $this->lists($objQuery); 
     194 
     195        // 配列のキーを商品IDに 
     196        $arrTmp = array(); 
     197        foreach($arrProducts as $arrProduct) { 
     198            $arrTmp[$arrProduct['product_id']] = $arrProduct; 
     199        } 
     200        $arrProducts =& $arrTmp; 
     201        unset($arrTmp); 
     202 
     203        // SC_Query::setOrder() の指定がない場合、$arrProductId で指定された商品IDの順に配列要素を並び替え 
     204        if (strlen($objQuery->order) === 0) { 
     205            $arrTmp = array(); 
     206            foreach($arrProductId as $product_id) { 
     207                $arrTmp[$product_id] = $arrProducts[$product_id]; 
     208            } 
     209            $arrProducts =& $arrTmp; 
     210            unset($arrTmp); 
     211        } 
     212 
     213        return $arrProducts; 
    195214    } 
    196215 
Note: See TracChangeset for help on using the changeset viewer.