/**
  * おすすめ商品検索.
  *
  * @return array $arrBestProducts 検索結果配列
  */
 public function lfGetRanking()
 {
     $objRecommend = new SC_Helper_BestProducts_Ex();
     // おすすめ商品取得
     $arrRecommends = $objRecommend->getList(RECOMMEND_NUM);
     $response = array();
     if (count($arrRecommends) > 0) {
         // 商品一覧を取得
         $objQuery =& SC_Query_Ex::getSingletonInstance();
         $objProduct = new SC_Product_Ex();
         // where条件生成&セット
         $arrProductId = array();
         foreach ($arrRecommends as $key => $val) {
             $arrProductId[] = $val['product_id'];
         }
         $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId);
         // 税込金額を設定する
         SC_Product_Ex::setIncTaxToProducts($arrProducts);
         // おすすめ商品情報にマージ
         foreach ($arrRecommends as $key => $value) {
             if (isset($arrProducts[$value['product_id']])) {
                 $product = $arrProducts[$value['product_id']];
                 if ($product['status'] == 1 && (!NOSTOCK_HIDDEN || ($product['stock_max'] >= 1 || $product['stock_unlimited_max'] == 1))) {
                     $response[] = array_merge($value, $arrProducts[$value['product_id']]);
                 }
             } else {
                 // 削除済み商品は除外
                 unset($arrRecommends[$key]);
             }
         }
     }
     return $response;
 }
 /**
  * 商品情報を取得する
  *
  * @param SC_Query $objQuery DB操作クラス
  * @param integer $product_id 商品ID
  * @return array $arrProduct 取得結果を配列で返す
  */
 function lfGetProductsDetail(&$objQuery, $product_id = 'all')
 {
     $objProduct = new SC_Product_Ex();
     // --- 商品詳細の取得
     if ($product_id == 'all') {
         $objQuery->setOrder('product_id');
         $arrProductLsit = $objProduct->lists($objQuery);
     } else {
         $arrProductLsit = $objProduct->getListByProductIds($objQuery, array($product_id));
     }
     // 各商品のカテゴリIDとランクの取得
     $arrProduct = array();
     foreach ($arrProductLsit as $key => $val) {
         $sql = '';
         $sql .= ' SELECT';
         $sql .= '   T1.category_id,';
         $sql .= '   T1.rank AS product_rank,';
         $sql .= '   T2.rank AS category_rank';
         $sql .= ' FROM';
         $sql .= '   dtb_product_categories AS T1';
         $sql .= ' LEFT JOIN';
         $sql .= '   dtb_category AS T2';
         $sql .= ' ON';
         $sql .= '   T1.category_id = T2.category_id';
         $sql .= ' WHERE';
         $sql .= '   product_id = ?';
         $arrCategory = $objQuery->getAll($sql, array($val['product_id']));
         if (!empty($arrCategory)) {
             $arrProduct[$key] = array_merge($val, $arrCategory[0]);
         }
     }
     return $arrProduct;
 }
 /**
  *
  * @param SC_Product_Ex $objProduct
  */
 public function lfGetProductsList($searchCondition, $disp_number, $startno, &$objProduct)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objDb = new SC_Helper_DB_Ex();
     $arrOrderVal = array();
     // 表示順序
     switch ($this->orderby) {
         // ダウンロード順
         case 'download':
             $status = ORDER_PRE_END;
             $objProduct->setProductsOrder('count(*)', "(SELECT B.* FROM dtb_order A INNER JOIN dtb_order_detail B USING(order_id) WHERE A.del_flg = 0 AND A.status = {$status})", 'ASC');
             break;
             // 販売価格が安い順
         // 販売価格が安い順
         case 'price':
             $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC');
             break;
             // 新着順
         // 新着順
         case 'date':
             if ($objDb->sfColumnExists('dtb_products', 'auto_display_start_date')) {
                 $objProduct->setProductsOrder('auto_display_start_date', 'dtb_products', 'DESC');
             } else {
                 $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC');
             }
             break;
         default:
             // FIXME 指定した カラムが損z内下場合はそのカラムをキーとする。
             if ($objDb->sfColumnExists('dtb_products', 'auto_display_start_date') && strlen($this->orderby) == 0) {
                 $objProduct->setProductsOrder('auto_display_start_date', 'dtb_products', 'DESC');
             } elseif ($objDb->sfColumnExists('dtb_products', $this->orderby)) {
                 $objProduct->setProductsOrder($this->orderby, 'dtb_products', 'DESC');
                 break;
             }
         case "rank":
             if (strlen($searchCondition['where_category']) >= 1) {
                 $dtb_product_categories = '(SELECT * FROM dtb_product_categories WHERE ' . $searchCondition['where_category'] . ')';
                 $arrOrderVal = $searchCondition['arrvalCategory'];
             } else {
                 $dtb_product_categories = 'dtb_product_categories';
             }
             $col = 'MAX(T3.rank * 2147483648 + T2.rank)';
             $from = "{$dtb_product_categories} T2 JOIN dtb_category T3 ON T2.category_id = T3.category_id";
             $where = 'T2.product_id = alldtl.product_id';
             $sub_sql = $objQuery->getSql($col, $from, $where);
             $objQuery->setOrder("({$sub_sql}) DESC ,product_id DESC");
             break;
     }
     // 取得範囲の指定(開始行番号、行数のセット)
     $objQuery->setLimitOffset($disp_number, $startno);
     $objQuery->setWhere($searchCondition['where']);
     // 表示すべきIDとそのIDの並び順を一気に取得
     $arrProductId = $objProduct->findProductIdsOrder($objQuery, array_merge($searchCondition['arrval'], $arrOrderVal));
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId);
     // 規格を設定
     $objProduct->setProductsClassByProductIds($arrProductId);
     $arrProducts['productStatus'] = $objProduct->getProductStatus($arrProductId);
     foreach ($arrProducts as $product_id => &$arrProduct) {
         if ($product_id == 'productStatus') {
             continue;
         }
         $category_id = $objProduct->getCategoryIds($product_id);
         $arrProduct["category_id"] = array_shift($category_id);
         $arrProduct["category"] = $this->arrCategory[$arrProduct["category_id"]];
         $arrProduct["category_name"] = $arrProduct["category"]["category_name"];
         if ($objDb->sfColumnExists('dtb_category', 'category_code')) {
             $arrProduct["category_code"] = $arrProduct["category"]["category_code"];
             $arrProduct["category_image1"] = $arrProduct["category"]["category_image1"] ?: 0;
             $arrProduct["category_image2"] = $arrProduct["category"]["category_image2"] ?: 0;
             $arrProduct["category_image3"] = $arrProduct["category"]["category_image3"] ?: 0;
             $arrProduct["category_image4"] = $arrProduct["category"]["category_image4"] ?: 0;
             $arrProduct["category_image5"] = $arrProduct["category"]["category_image5"] ?: 0;
         }
     }
     return $arrProducts;
 }
 function lfPreGetRecommendProducts($product_id)
 {
     $objProduct = new SC_Product_Ex();
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->setOrder('rank DESC');
     $arrRecommendData = $objQuery->select('recommend_product_id, comment', 'dtb_recommend_products as t1 left join dtb_products as t2 on t1.recommend_product_id = t2.product_id', 't1.product_id = ? and t2.del_flg = 0 and t2.status = 1', array($product_id));
     $arrRecommendProductId = array();
     foreach ($arrRecommendData as $recommend) {
         $arrRecommendProductId[] = $recommend['recommend_product_id'];
     }
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $arrRecommendProductId);
     $arrRecommend = array();
     foreach ($arrRecommendData as $key => $arrRow) {
         $arrRecommendData[$key] = array_merge($arrRow, $arrProducts[$arrRow['recommend_product_id']]);
     }
     return $arrRecommendData;
 }
 function lfPreGetRecommendProducts($product_id)
 {
     $objProduct = new SC_Product_Ex();
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->setOrder("rank DESC");
     $arrRecommendData = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
     $arrRecommendProductId = array();
     foreach ($arrRecommendData as $recommend) {
         $arrRecommendProductId[] = $recommend["recommend_product_id"];
         $arrRecommendData[$recommend["recommend_product_id"]] = $recommend['comment'];
     }
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $arrRecommendProductId);
     //取得している並び順で並び替え
     // FIXME SC_Productあたりにソート処理はもってくべき
     $arrProducts2 = array();
     foreach ($arrProducts as $item) {
         $arrProducts2[$item['product_id']] = $item;
     }
     $arrRecommend = array();
     foreach ($arrRecommendProductId as $product_id) {
         $arrProducts2[$product_id]['comment'] = $arrRecommendData[$product_id];
         $arrRecommend[] = $arrProducts2[$product_id];
     }
     return $arrRecommend;
 }
Example #6
0
 /**
  * @param SC_Product_Ex $objProduct
  */
 public function lfGetProductsList($searchCondition, $disp_number, $startno, &$objProduct)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrOrderVal = array();
     // 表示順序
     switch ($this->orderby) {
         // 販売価格が安い順
         case 'price':
             $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC');
             break;
             // 新着順
         // 新着順
         case 'date':
             $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC');
             break;
         default:
             if (strlen($searchCondition['where_category']) >= 1) {
                 $dtb_product_categories = '(SELECT * FROM dtb_product_categories WHERE ' . $searchCondition['where_category'] . ')';
                 $arrOrderVal = $searchCondition['arrvalCategory'];
             } else {
                 $dtb_product_categories = 'dtb_product_categories';
             }
             $col = 'MAX(T3.rank * 2147483648 + T2.rank)';
             $from = "{$dtb_product_categories} T2 JOIN dtb_category T3 ON T2.category_id = T3.category_id";
             $where = 'T2.product_id = alldtl.product_id';
             $sub_sql = $objQuery->getSql($col, $from, $where);
             $objQuery->setOrder("({$sub_sql}) DESC ,product_id DESC");
             break;
     }
     // 取得範囲の指定(開始行番号、行数のセット)
     $objQuery->setLimitOffset($disp_number, $startno);
     $objQuery->setWhere($searchCondition['where']);
     // 表示すべきIDとそのIDの並び順を一気に取得
     $arrProductId = $objProduct->findProductIdsOrder($objQuery, array_merge($searchCondition['arrval'], $arrOrderVal));
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId);
     // 規格を設定
     $objProduct->setProductsClassByProductIds($arrProductId);
     $arrProducts['productStatus'] = $objProduct->getProductStatus($arrProductId);
     return $arrProducts;
 }
 /**
  * おすすめ商品検索.
  *
  * @return array $arrBestProducts 検索結果配列
  */
 function lfGetRanking()
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     // おすすめ商品取得
     $col = 'T1.best_id, T1.category_id, T1.rank, T1.product_id, T1.title, T1.comment, T1.create_date, T1.update_date';
     $table = 'dtb_best_products as T1 INNER JOIN dtb_products as T2 ON T1.product_id = T2.product_id';
     $where = 'T1.del_flg = 0 and T2.status = 1';
     $objQuery->setOrder('T1.rank');
     $objQuery->setLimit(RECOMMEND_NUM);
     $arrBestProducts = $objQuery->select($col, $table, $where);
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     if (count($arrBestProducts) > 0) {
         // 商品一覧を取得
         // where条件生成&セット
         $arrProductId = array();
         $where = 'product_id IN (';
         foreach ($arrBestProducts as $key => $val) {
             $arrProductId[] = $val['product_id'];
         }
         // 取得
         $arrProductList = $objProduct->getListByProductIds($objQuery, $arrProductId);
         // おすすめ商品情報にマージ
         foreach ($arrBestProducts as $key => $value) {
             $arrRow =& $arrBestProducts[$key];
             if (isset($arrProductList[$arrRow['product_id']])) {
                 $arrRow = array_merge($arrRow, $arrProductList[$arrRow['product_id']]);
             } else {
                 // 削除済み商品は除外
                 unset($arrBestProducts[$key]);
             }
         }
     }
     return $arrBestProducts;
 }
 /**
  * 新着商品の情報を取得
  *
  * @return array
  * @setcookie array
  */
 function lfGetVideoPlayer()
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     // プラグイン情報を取得.
     $plugin = SC_Plugin_Util_Ex::getPluginByPluginCode("VideoPlayer");
     //表示条件
     $disp_rule = is_numeric($plugin['free_field1']) ? $plugin['free_field1'] : 0;
     //表示件数
     $disp_count = unserialize($plugin['free_field2']);
     //表示ステータス
     $product_status = $plugin['free_field3'];
     //デバイスフラグ
     $disp_device == SC_Display_Ex::detectDevice();
     // 新着商品情報取得
     $col = 'product_id';
     $table = 'dtb_products';
     $where = 'status = 1 and del_flg = 0';
     if ($product_status) {
         $arrStatus = unserialize($product_status);
         if (is_array($arrStatus)) {
             $strstatus = '';
             foreach ($arrStatus as $status) {
                 if ($strstatus) {
                     $strstatus .= ',';
                 }
                 $strstatus .= $status;
             }
             $where .= ' ' . 'AND product_id IN (' . '    SELECT product_id FROM dtb_product_status WHERE product_status_id IN (' . $strstatus . ')' . ')';
         }
     }
     switch ($disp_rule) {
         case 1:
             //登録日順
             $objQuery->setOrder('create_date desc');
             break;
         case 2:
             //更新日順
             $objQuery->setOrder('update_date desc');
             break;
     }
     if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_PC) {
         $objQuery->setLimit($disp_count[10]);
     } elseif (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
         $objQuery->setLimit($disp_count[1]);
     } elseif (SC_Display_Ex::detectDevice() == DEVICE_TYPE_SMARTPHONE) {
         $objQuery->setLimit($disp_count[2]);
     }
     $arrProducts = $objQuery->select($col, $table, $where);
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     if (count($arrProducts) > 0) {
         $arrProductId = array();
         foreach ($arrProducts as $key => $val) {
             $arrProductId[] = $val['product_id'];
         }
         // 商品詳細情報取得
         $arrTmp = $objProduct->getListByProductIds($objQuery, $arrProductId);
         foreach ($arrTmp as $key => $arrRow) {
             $_row = $arrRow;
             $arrProductList[] = $_row;
         }
     }
     return $arrProductList;
 }
 /**
  * 既に登録されている内容を取得する
  * @param  SC_Helper_BestProducts_Ex $objRecommend
  * @return Array  $arrReturnProducts データベースに登録されているおすすめ商品の配列
  */
 public function getRecommendProducts(SC_Helper_BestProducts_Ex &$objRecommend)
 {
     $arrList = $objRecommend->getList();
     // product_id の一覧を作成
     $product_ids = array();
     foreach ($arrList as $value) {
         $product_ids[] = $value['product_id'];
     }
     $objProduct = new SC_Product_Ex();
     $objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $product_ids);
     $arrReturnProducts = array();
     foreach ($arrList as $data) {
         $data['main_list_image'] = $arrProducts[$data['product_id']]['main_list_image'];
         $data['name'] = $arrProducts[$data['product_id']]['name'];
         $arrReturnProducts[$data['rank']] = $data;
     }
     return $arrReturnProducts;
 }
 /**
  * おすすめ商品検索.
  *
  * @return array $arrBestProducts 検索結果配列
  */
 function lfGetRanking()
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     // おすすめ商品取得
     $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);
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     if (count($arrBestProducts) > 0) {
         // 商品一覧を取得
         // where条件生成&セット
         $arrProductId = array();
         $where = 'product_id IN (';
         foreach ($arrBestProducts as $key => $val) {
             $arrProductId[] = $val['product_id'];
         }
         // 取得
         $arrTmp = $objProduct->getListByProductIds($objQuery, $arrProductId);
         foreach ($arrTmp as $key => $arrRow) {
             $arrProductList[$arrRow['product_id']] = $arrRow;
         }
         // おすすめ商品情報にマージ
         foreach (array_keys($arrBestProducts) as $key) {
             $arrRow =& $arrBestProducts[$key];
             if (isset($arrProductList[$arrRow['product_id']])) {
                 $arrRow = array_merge($arrRow, $arrProductList[$arrRow['product_id']]);
             } else {
                 // 削除済み商品は除外
                 unset($arrBestProducts[$key]);
             }
         }
     }
     return $arrBestProducts;
 }