/**
  * おすすめ商品検索.
  *
  * @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;
 }
 public function testRankDown_指定されたデータがランクダウンされる()
 {
     $objRecommend = new SC_Helper_BestProducts_Ex();
     $objRecommend->rankDown("1001");
     $this->expected = "2";
     $arrRet = $objRecommend->getBestProducts('1001');
     $this->actual = $arrRet['rank'];
     $this->verify();
 }
 public function testDeleteByProductIDs_複数データが削除される()
 {
     $objHelperBestProducts = new SC_Helper_BestProducts_Ex();
     $objHelperBestProducts->deleteByProductIDs(array("2", "3"));
     $this->expected = null;
     $this->actual = $objHelperBestProducts->getBestProducts('1001');
     $this->verify();
     $this->actual = $objHelperBestProducts->getBestProducts('1003');
     $this->verify();
 }
 public function testGetList_ページングが想定した結果が返る_表示件数1_ページ番号0()
 {
     $this->setUpBestProducts();
     $this->expected = array(0 => array('best_id' => '1001', 'product_id' => '2', 'category_id' => '0', 'rank' => '1', 'title' => 'タイトルですよ', 'comment' => 'コメントですよ', 'creator_id' => '1', 'create_date' => '2000-01-01 00:00:00', 'update_date' => '2000-01-01 00:00:00', 'del_flg' => '0'));
     $this->actual = SC_Helper_BestProducts_Ex::getList(1, 0);
     $this->verify();
 }
 public function testGetByRank_ランクが存在かつ_has_deletedの場合_対応した結果が返る()
 {
     $rank = '2';
     $this->expected = array('best_id' => '1002', 'category_id' => '0', 'title' => 'タイトルですよ', 'comment' => 'コメントですよ', 'del_flg' => '1');
     $result = SC_Helper_BestProducts_Ex::getByRank($rank, true);
     $this->actual = Test_Utils::mapArray($result, array('best_id', 'category_id', 'title', 'comment', 'del_flg'));
     $this->verify();
 }
 public function testDeleteBestProducts_データ削除後_ランクは変動しない()
 {
     SC_Helper_BestProducts_Ex::deleteBestProducts("1001");
     $this->expected = "2";
     $arrRet = SC_Helper_BestProducts_Ex::getBestProducts('1002', true);
     $this->actual = $arrRet['rank'];
     $this->verify();
 }
 public function testRankUp_指定されたデータがランクアップされる()
 {
     SC_Helper_BestProducts_Ex::rankUp("1003");
     $this->expected = "2";
     $arrRet = SC_Helper_BestProducts_Ex::getBestProducts('1003');
     $this->actual = $arrRet['rank'];
     $this->verify();
 }
 public function testGetBestProducts_削除済みでかつhas_deletedがtrueの場合_対応した結果が返る()
 {
     $best_id = '1002';
     $this->expected = array('category_id' => '0', 'rank' => '2', 'title' => 'タイトルですよ', 'comment' => 'コメントですよ', 'del_flg' => '1');
     $result = SC_Helper_BestProducts_Ex::getBestProducts($best_id, true);
     $this->actual = Test_Utils::mapArray($result, array('category_id', 'rank', 'title', 'comment', 'del_flg'));
     $this->verify();
 }
 public function testRankDown_指定されたデータがランクダウンされる()
 {
     SC_Helper_BestProducts_Ex::rankDown("1001");
     $this->expected = "2";
     $arrRet = SC_Helper_BestProducts_Ex::getBestProducts('1001');
     $this->actual = $arrRet['rank'];
     $this->verify();
 }
 public function testSaveBestProducts_インサート処理でrankがsetされてない場合_採番された値がセットされる()
 {
     if (DB_TYPE != 'pgsql') {
         //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避
         $sqlVal = array('product_id' => '5', 'category_id' => '2', 'title' => 'タイトルですよ5', 'comment' => 'コメントですよ5', 'creator_id' => '3', 'del_flg' => '0');
         $best_id = SC_Helper_BestProducts_Ex::saveBestProducts($sqlVal);
         $this->expected = "4";
         //ランク
         $arrRet = SC_Helper_BestProducts_Ex::getBestProducts($best_id);
         $this->actual = $arrRet['rank'];
         $this->verify();
     }
 }
 /**
  * データを削除する
  * @param  Array  $arrPost      POSTの値を格納した配列
  * @param  SC_Helper_BestProducts_Ex $objRecommend
  * @return void
  */
 public function deleteProduct($arrPost, SC_Helper_BestProducts_Ex &$objRecommend)
 {
     if ($arrPost['best_id']) {
         $target = $arrPost['best_id'];
     } else {
         $recommend = $objRecommend->getByRank($arrPost['rank']);
         $target = $recommend['best_id'];
     }
     $objRecommend->deleteBestProducts($target);
 }
Ejemplo n.º 12
0
 /**
  * 商品、子テーブル(商品規格)、お気に入り商品の削除
  *
  * @param  string $where    削除対象の WHERE 句
  * @param  array  $arrParam 削除対象の値
  * @return void
  */
 public function doDelete($where, $arrParam = array())
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $product_ids = $objQuery->getCol('product_id', "dtb_products", $where, $arrParam);
     $sqlval['del_flg'] = 1;
     $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
     $objQuery->begin();
     $objQuery->update('dtb_products_class', $sqlval, "product_id IN (SELECT product_id FROM dtb_products WHERE {$where})", $arrParam);
     $objQuery->delete('dtb_customer_favorite_products', "product_id IN (SELECT product_id FROM dtb_products WHERE {$where})", $arrParam);
     $objRecommend = new SC_Helper_BestProducts_Ex();
     $objRecommend->deleteByProductIDs($product_ids);
     $objQuery->update('dtb_products', $sqlval, $where, $arrParam);
     $objQuery->commit();
 }