Changeset 22582
- Timestamp:
- 2013/02/26 09:09:44 (10 years ago)
- Location:
- branches/version-2_12-dev/data
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/Smarty/templates/admin/contents/recommend.tpl
r22572 r22582 21 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 22 */ 23 *}--> 23 24 *}--> 24 25 25 26 <script type="text/javascript"> … … 75 76 if ( flag ){ 76 77 document.form1["mode"].value = mode; 77 document.form1[" rank"].value = data;78 document.form1["best_id"].value = data; 78 79 document.form1.submit(); 79 80 } … … 117 118 <input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" /> 118 119 <input type="hidden" name="mode" value="regist" /> 120 <input type="hidden" name="best_id" value="<!--{$arrItems[$smarty.section.cnt.iteration].best_id|h}-->" /> 119 121 <input type="hidden" name="product_id" value="<!--{$arrItems[$smarty.section.cnt.iteration].product_id|h}-->" /> 120 122 <input type="hidden" name="category_id" value="<!--{$category_id|h}-->" /> … … 133 135 <input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" /> 134 136 <input type="hidden" name="mode" value="regist" /> 137 <input type="hidden" name="best_id" value="<!--{$arrItems[$smarty.section.cnt.iteration].best_id|h}-->" /> 135 138 <input type="hidden" name="product_id" value="<!--{$arrItems[$smarty.section.cnt.iteration].product_id|h}-->" /> 136 139 <input type="hidden" name="category_id" value="<!--{$category_id|h}-->" /> … … 158 161 <!--{* 移動 *}--> 159 162 <!--{if $smarty.section.cnt.iteration != 1 && $arrItems[$smarty.section.cnt.iteration].product_id}--> 160 <a href="?" onclick="lfnSortItem('up',<!--{$arrItems[$smarty.section.cnt.iteration]. rank}-->); return false;">上へ</a><br /> 163 <a href="?" onclick="lfnSortItem('up',<!--{$arrItems[$smarty.section.cnt.iteration].best_id}-->); return false;">上へ</a><br /> 161 164 <!--{/if}--> 162 165 <!--{if $smarty.section.cnt.iteration != $tpl_disp_max && $arrItems[$smarty.section.cnt.iteration].product_id}--> 163 <a href="?" onclick="lfnSortItem('down',<!--{$arrItems[$smarty.section.cnt.iteration]. rank}-->); return false;">下へ</a>166 <a href="?" onclick="lfnSortItem('down',<!--{$arrItems[$smarty.section.cnt.iteration].best_id}-->); return false;">下へ</a> 164 167 <!--{/if}--> 165 168 </td> -
branches/version-2_12-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_Recommend.php
r22567 r22582 77 77 $objFormParam->setParam($_POST); 78 78 $objFormParam->convParam(); 79 $objQuery =& SC_Query_Ex::getSingletonInstance(); 80 $objDb = new SC_Helper_DB_Ex(); 79 $arrPost = $objFormParam->getHashArray(); 80 81 $objRecommend = new SC_Helper_Recommend_Ex(); 81 82 82 83 switch ($this->getMode()) { 83 case 'down': //商品の並び替えをする。おすすめはデータベースの登録が昇順なので、Modeを逆にする。 84 $arrRet = $objQuery->select('best_id', 'dtb_best_products', 'rank = ?', array($_POST['rank'])); //おすすめidの取得 85 $best_id = $arrRet[0]['best_id']; 86 $objDb->sfRankUp('dtb_best_products','best_id',$best_id); 87 $arrPost = $objFormParam->getHashArray(); 88 $arrItems = $this->getRecommendProducts(); 89 break; 90 91 case 'up': //商品の並び替えをする。おすすめのみデータベースの登録が昇順なので、Modeを逆にする。 92 $arrRet = $objQuery->select('best_id', 'dtb_best_products', 'rank = ?', array($_POST['rank'])); //おすすめidの取得 93 $best_id = $arrRet[0]['best_id']; 94 $objDb->sfRankDown('dtb_best_products','best_id',$best_id); 95 $arrPost = $objFormParam->getHashArray(); 96 $arrItems = $this->getRecommendProducts(); 84 case 'down': //商品の並び替えをする。 85 $objRecommend->rankDown($arrPost['best_id']); 86 $arrItems = $this->getRecommendProducts($objRecommend); 87 break; 88 89 case 'up': //商品の並び替えをする。 90 $objRecommend->rankUp($arrPost['best_id']); 91 $arrItems = $this->getRecommendProducts($objRecommend); 97 92 break; 98 93 99 94 case 'regist': // 商品を登録する。 100 95 $this->arrErr = $this->lfCheckError($objFormParam); 101 $arrPost = $objFormParam->getHashArray();102 96 // 登録処理にエラーがあった場合は商品選択の時と同じ処理を行う。 103 97 if (SC_Utils_Ex::isBlank($this->arrErr)) { 104 98 $member_id = $_SESSION['member_id']; 105 $this->insertRecommendProduct($arrPost,$member_id );106 $arrItems = $this->getRecommendProducts( );99 $this->insertRecommendProduct($arrPost,$member_id,$objRecommend); 100 $arrItems = $this->getRecommendProducts($objRecommend); 107 101 } else { 108 102 $arrItems = $this->setProducts($arrPost, $arrItems); … … 113 107 case 'delete': // 商品を削除する。 114 108 $this->arrErr = $this->lfCheckError($objFormParam); 115 $arrPost = $objFormParam->getHashArray();116 109 if (SC_Utils_Ex::isBlank($this->arrErr)) { 117 $this->deleteProduct($arrPost );118 $arrItems = $this->getRecommendProducts( );110 $this->deleteProduct($arrPost, $objRecommend); 111 $arrItems = $this->getRecommendProducts($objRecommend); 119 112 } 120 113 $this->tpl_onload = "window.alert('削除しました');"; … … 124 117 $arrPost = $objFormParam->getHashArray(); 125 118 if (SC_Utils_Ex::isBlank($this->arrErr['rank']) && SC_Utils_Ex::isBlank($this->arrErr['product_id'])) { 126 $arrItems = $this->setProducts($arrPost, $this->getRecommendProducts( ));119 $arrItems = $this->setProducts($arrPost, $this->getRecommendProducts($objRecommend)); 127 120 $this->checkRank = $arrPost['rank']; 128 121 } 129 122 break; 130 123 default: 131 $arrItems = $this->getRecommendProducts( );124 $arrItems = $this->getRecommendProducts($objRecommend); 132 125 break; 133 126 } … … 158 151 function lfInitParam(&$objFormParam) 159 152 { 153 $objFormParam->addParam('おすすめ商品ID', 'best_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); 160 154 $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); 161 155 $objFormParam->addParam('カテゴリID', 'category_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); … … 178 172 /** 179 173 * 既に登録されている内容を取得する 174 * @param Object $objRecommend 180 175 * @return Array $arrReturnProducts データベースに登録されているおすすめ商品の配列 181 176 */ 182 function getRecommendProducts() 183 { 177 function getRecommendProducts(SC_Helper_Recommend_Ex &$objRecommend) 178 { 179 $arrList = $objRecommend->getList(); 180 // product_id の一覧を作成 181 $product_ids = array(); 182 foreach ($arrList as $value) { 183 $product_ids[] = $value['product_id']; 184 } 185 186 $objProduct = new SC_Product_Ex; 184 187 $objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance(); 185 $col = 'dtb_products.name,dtb_products.main_list_image,dtb_best_products.*,dtb_products.status'; 186 $table = 'dtb_best_products INNER JOIN dtb_products ON dtb_best_products.product_id = dtb_products.product_id'; 187 $where = 'dtb_best_products.del_flg = 0'; 188 $order = 'rank'; 189 $objQuery->setOrder($order); 190 $arrProducts = $objQuery->select($col, $table, $where); 188 $arrProducts = $objProduct->getListByProductIds($objQuery, $product_ids); 191 189 192 190 $arrReturnProducts = array(); 193 foreach ($arrProducts as $data) { 191 foreach ($arrList as $data) { 192 $data['main_list_image'] = $arrProducts[$data['product_id']]['main_list_image']; 193 $data['name'] = $arrProducts[$data['product_id']]['name']; 194 194 $arrReturnProducts[$data['rank']] = $data; 195 195 } … … 201 201 * @param Array $arrPost POSTの値を格納した配列 202 202 * @param Integer $member_id 登録した管理者を示すID 203 * /204 function insertRecommendProduct($arrPost,$member_id)205 {206 $objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance();203 * @param Object $objRecommend 204 */ 205 function insertRecommendProduct($arrPost,$member_id, SC_Helper_Recommend_Ex &$objRecommend) 206 { 207 207 // 古いおすすめ商品のデータを削除する。 208 $this->deleteProduct($arrPost );208 $this->deleteProduct($arrPost, $objRecommend); 209 209 210 210 $sqlval = array(); … … 214 214 $sqlval['comment'] = $arrPost['comment']; 215 215 $sqlval['creator_id'] = $member_id; 216 $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; 217 $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; 218 $sqlval['best_id'] = $objQuery->nextVal('dtb_best_products_best_id'); 219 $objQuery->insert('dtb_best_products', $sqlval); 216 $objRecommend->save($sqlval); 220 217 } 221 218 … … 223 220 * データを削除する 224 221 * @param Array $arrPost POSTの値を格納した配列 225 */ 226 function deleteProduct($arrPost) 227 { 228 $objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance(); 229 $table = 'dtb_best_products'; 230 $where = 'category_id = ? AND rank = ?'; 231 $arrWhereVal = array($arrPost['category_id'],$arrPost['rank']); 232 $objQuery->delete($table, $where, $arrWhereVal); 222 * @param Object $objRecommend 223 * @return void 224 */ 225 function deleteProduct($arrPost, SC_Helper_Recommend_Ex &$objRecommend) 226 { 227 if ($arrPost['best_id']) { 228 $target = $arrPost['best_id']; 229 } else { 230 $recommend = $objRecommend->getByRank($arrPost['rank']); 231 $target = $recommend['best_id']; 232 } 233 $objRecommend->delete($target); 233 234 } 234 235 … … 236 237 * 商品情報を取得する 237 238 * @param Integer $product_id 商品ID 238 * @return Array $ arrProduct商品のデータを格納した配列239 * @return Array $return 商品のデータを格納した配列 239 240 */ 240 241 function getProduct($product_id) 241 242 { 242 $objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance(); 243 $col = 'product_id,main_list_image,name'; 244 $table = 'dtb_products'; 245 $where = 'product_id = ? AND del_flg = 0'; 246 $arrWhereVal = array($product_id); 247 $arrProduct = $objQuery->select($col, $table, $where, $arrWhereVal); 248 return $arrProduct[0]; 243 $objProduct = new SC_Product_Ex(); 244 $arrProduct = $objProduct->getDetail($product_id); 245 $return = array( 246 'product_id' => $arrProduct['product_id'], 247 'main_list_image' => $arrProduct['main_list_image'], 248 'name' => $arrProduct['name'] 249 ); 250 return $return; 249 251 } 250 252 -
branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products.php
r22577 r22582 266 266 { 267 267 $objQuery =& SC_Query_Ex::getSingletonInstance(); 268 $arrRet = $objQuery->getCol('product_id', "dtb_products", $where, $arrParam); 269 $product_ids = array(); 270 foreach ($arrRet as $value) { 271 $product_ids[] = $value['product_id']; 272 } 268 273 $sqlval['del_flg'] = 1; 269 274 $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; … … 271 276 $objQuery->update('dtb_products_class', $sqlval, "product_id IN (SELECT product_id FROM dtb_products WHERE $where)", $arrParam); 272 277 $objQuery->delete('dtb_customer_favorite_products', "product_id IN (SELECT product_id FROM dtb_products WHERE $where)", $arrParam); 273 $objQuery->delete('dtb_best_products', "product_id IN (SELECT product_id FROM dtb_products WHERE $where)", $arrParam); 278 279 $objRecomment = new SC_Helper_Recommend_Ex(); 280 $objRecomment->deleteByProductIDs($product_ids); 281 274 282 $objQuery->update('dtb_products', $sqlval, $where, $arrParam); 275 283 $objQuery->commit(); -
branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php
r22567 r22582 94 94 function lfGetRanking() 95 95 { 96 $objQuery =& SC_Query_Ex::getSingletonInstance(); 97 $objProduct = new SC_Product_Ex(); 96 $objRecommend = new SC_Helper_Recommend_Ex(); 98 97 99 98 // おすすめ商品取得 100 $col = 'T1.best_id, T1.category_id, T1.rank, T1.product_id, T1.title, T1.comment, T1.create_date, T1.update_date'; 101 $table = 'dtb_best_products as T1 INNER JOIN dtb_products as T2 ON T1.product_id = T2.product_id'; 102 $where = 'T1.del_flg = 0 and T2.status = 1'; 103 if (NOSTOCK_HIDDEN) { 104 $where .= ' AND EXISTS(SELECT * FROM dtb_products_class WHERE product_id = T1.product_id AND dtb_products_class.del_flg = 0 AND (stock >= 1 OR stock_unlimited = 1))'; 105 } 106 $objQuery->setOrder('T1.rank'); 107 $objQuery->setLimit(RECOMMEND_NUM); 108 $arrBestProducts = $objQuery->select($col, $table, $where); 99 $arrRecommends = $objRecommend->getList(RECOMMEND_NUM); 109 100 110 $ objQuery =& SC_Query_Ex::getSingletonInstance();111 if (count($arr BestProducts) > 0) {101 $response = array(); 102 if (count($arrRecommends) > 0) { 112 103 // 商品一覧を取得 104 $objQuery =& SC_Query_Ex::getSingletonInstance(); 105 $objProduct = new SC_Product_Ex(); 113 106 // where条件生成&セット 114 107 $arrProductId = array(); 115 $where = 'product_id IN ('; 116 foreach ($arrBestProducts as $key => $val) { 108 foreach ($arrRecommends as $key => $val) { 117 109 $arrProductId[] = $val['product_id']; 118 110 } 119 // 取得 120 $arrProductList = $objProduct->getListByProductIds($objQuery, $arrProductId); 111 $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId); 112 113 // 税込金額を設定する 114 SC_Product_Ex::setIncTaxToProducts($arrProducts); 115 121 116 // おすすめ商品情報にマージ 122 foreach ($arrBestProducts as $key => $value) { 123 $arrRow =& $arrBestProducts[$key]; 124 if (isset($arrProductList[$arrRow['product_id']])) { 125 $arrRow = array_merge($arrRow, $arrProductList[$arrRow['product_id']]); 117 foreach ($arrRecommends as $key => $value) { 118 if (isset($arrProducts[$value['product_id']])) { 119 $product = $arrProducts[$value['product_id']]; 120 if (!NOSTOCK_HIDDEN || ($product['status'] == 1 && ($product['stock_max'] >= 1 || $product['stock_unlimited_max'] == 1))) { 121 $response[] = array_merge($value, $arrProducts[$value['product_id']]); 122 } 126 123 } else { 127 124 // 削除済み商品は除外 128 unset($arr BestProducts[$key]);125 unset($arrRecommends[$key]); 129 126 } 130 127 } 131 128 } 132 return $ arrBestProducts;129 return $response; 133 130 } 134 131 }
Note: See TracChangeset
for help on using the changeset viewer.