[Svn-src-all:3670] [version-2_12-dev 22582] #2162 pageクラスからdtb_best_productsテーブルを直接指定している箇所をなくす
pineray
admin @ mail.ec-cube.net
2013年 2月 26日 (火) 09:09:44 JST
Subversion committed to /home/svn/open 22582
http://svn.ec-cube.net/open_trac/changeset/22582
┌────────────────────────────┐
│更新者 : pineray │
│更新日時: 2013-02-26 09:09:44 +0900 (火, 26 2月 2013)│
└────────────────────────────┘
Log:
--------------------------------------------------------
#2162 pageクラスからdtb_best_productsテーブルを直接指定している箇所をなくす
Changed: [U:修正,A:追加,D:削除]
--------------------------------------------------------
U branches/version-2_12-dev/data/Smarty/templates/admin/contents/recommend.tpl
A branches/version-2_12-dev/data/class/helper/SC_Helper_Recommend.php
U branches/version-2_12-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_Recommend.php
U branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products.php
U branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php
A branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Recommend_Ex.php
変更: branches/version-2_12-dev/data/Smarty/templates/admin/contents/recommend.tpl
===================================================================
--- branches/version-2_12-dev/data/Smarty/templates/admin/contents/recommend.tpl 2013-02-22 11:22:51 UTC (rev 22581)
+++ branches/version-2_12-dev/data/Smarty/templates/admin/contents/recommend.tpl 2013-02-26 00:09:44 UTC (rev 22582)
@@ -20,8 +20,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-*}-->
+ *}-->
+
<script type="text/javascript">
<!--
function lfnCheckSubmit( fm ){
@@ -74,7 +75,7 @@
if ( flag ){
document.form1["mode"].value = mode;
- document.form1["rank"].value = data;
+ document.form1["best_id"].value = data;
document.form1.submit();
}
}
@@ -116,6 +117,7 @@
<form name="form<!--{$smarty.section.cnt.iteration}-->" id="form<!--{$smarty.section.cnt.iteration}-->" method="post" action="?">
<input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" />
<input type="hidden" name="mode" value="regist" />
+ <input type="hidden" name="best_id" value="<!--{$arrItems[$smarty.section.cnt.iteration].best_id|h}-->" />
<input type="hidden" name="product_id" value="<!--{$arrItems[$smarty.section.cnt.iteration].product_id|h}-->" />
<input type="hidden" name="category_id" value="<!--{$category_id|h}-->" />
<input type="hidden" name="rank" value="<!--{$arrItems[$smarty.section.cnt.iteration].rank|h}-->" />
@@ -132,6 +134,7 @@
<form name="form<!--{$smarty.section.cnt.iteration}-->" id="form<!--{$smarty.section.cnt.iteration}-->" method="post" action="?">
<input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" />
<input type="hidden" name="mode" value="regist" />
+ <input type="hidden" name="best_id" value="<!--{$arrItems[$smarty.section.cnt.iteration].best_id|h}-->" />
<input type="hidden" name="product_id" value="<!--{$arrItems[$smarty.section.cnt.iteration].product_id|h}-->" />
<input type="hidden" name="category_id" value="<!--{$category_id|h}-->" />
<input type="hidden" name="rank" value="<!--{$arrItems[$smarty.section.cnt.iteration].rank|h}-->" />
@@ -157,10 +160,10 @@
<td>
<!--{* 移動 *}-->
<!--{if $smarty.section.cnt.iteration != 1 && $arrItems[$smarty.section.cnt.iteration].product_id}-->
- <a href="?" onclick="lfnSortItem('up',<!--{$arrItems[$smarty.section.cnt.iteration].rank}-->); return false;">上へ</a><br />
+ <a href="?" onclick="lfnSortItem('up',<!--{$arrItems[$smarty.section.cnt.iteration].best_id}-->); return false;">上へ</a><br />
<!--{/if}-->
<!--{if $smarty.section.cnt.iteration != $tpl_disp_max && $arrItems[$smarty.section.cnt.iteration].product_id}-->
- <a href="?" onclick="lfnSortItem('down',<!--{$arrItems[$smarty.section.cnt.iteration].rank}-->); return false;">下へ</a>
+ <a href="?" onclick="lfnSortItem('down',<!--{$arrItems[$smarty.section.cnt.iteration].best_id}-->); return false;">下へ</a>
<!--{/if}-->
</td>
</tr>
追加: branches/version-2_12-dev/data/class/helper/SC_Helper_Recommend.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Recommend.php (rev 0)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Recommend.php 2013-02-26 00:09:44 UTC (rev 22582)
@@ -0,0 +1,186 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * おすすめ商品を管理するヘルパークラス.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Recommend
+{
+ /**
+ * おすすめ商品の情報を取得.
+ *
+ * @param integer $best_id おすすめ商品ID
+ * @param boolean $has_deleted 削除されたおすすめ商品も含む場合 true; 初期値 false
+ * @return array
+ */
+ public function get($best_id, $has_deleted = false)
+ {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $col = '*';
+ $where = 'best_id = ?';
+ if (!$has_deleted) {
+ $where .= ' AND del_flg = 0';
+ }
+ $arrRet = $objQuery->select($col, 'dtb_best_products', $where, array($best_id));
+ return $arrRet[0];
+ }
+
+ /**
+ * おすすめ商品の情報をランクから取得.
+ *
+ * @param integer $rank ランク
+ * @param boolean $has_deleted 削除されたおすすめ商品も含む場合 true; 初期値 false
+ * @return array
+ */
+ public function getByRank($rank, $has_deleted = false)
+ {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $col = '*';
+ $where = 'rank = ?';
+ if (!$has_deleted) {
+ $where .= ' AND del_flg = 0';
+ }
+ $arrRet = $objQuery->select($col, 'dtb_best_products', $where, array($rank));
+ return $arrRet[0];
+ }
+
+ /**
+ * おすすめ商品一覧の取得.
+ *
+ * @param integer $dispNumber 表示件数
+ * @param integer $pageNumber ページ番号
+ * @param boolean $has_deleted 削除されたおすすめ商品も含む場合 true; 初期値 false
+ * @return array
+ */
+ public function getList($dispNumber = 0, $pageNumber = 0, $has_deleted = false)
+ {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $col = '*';
+ $where = '';
+ if (!$has_deleted) {
+ $where .= 'del_flg = 0';
+ }
+ $table = 'dtb_best_products';
+ $objQuery->setOrder('rank');
+ if ($dispNumber > 0) {
+ if ($pageNumber > 0) {
+ $objQuery->setLimitOffset($dispNumber, (($pageNumber - 1) * $dispNumber));
+ } else {
+ $objQuery->setLimit($dispNumber);
+ }
+ }
+ $arrRet = $objQuery->select($col, $table, $where);
+ return $arrRet;
+ }
+
+ /**
+ * おすすめ商品の登録.
+ *
+ * @param array $sqlval
+ * @return multiple 登録成功:おすすめ商品ID, 失敗:FALSE
+ */
+ public function save($sqlval)
+ {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+
+ $best_id = $sqlval['best_id'];
+ $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
+ // 新規登録
+ if ($best_id == '') {
+ // INSERTの実行
+ if (!$sqlval['rank']) {
+ $sqlval['rank'] = $objQuery->max('rank', 'dtb_best_products') + 1;
+ }
+ $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
+ $sqlval['best_id'] = $objQuery->nextVal('dtb_best_products_best_id');
+ $ret = $objQuery->insert('dtb_best_products', $sqlval);
+ // 既存編集
+ } else {
+ unset($sqlval['creator_id']);
+ unset($sqlval['create_date']);
+ $where = 'best_id = ?';
+ $ret = $objQuery->update('dtb_best_products', $sqlval, $where, array($best_id));
+ }
+ return ($ret) ? $sqlval['best_id'] : FALSE;
+ }
+
+ /**
+ * おすすめ商品の削除.
+ *
+ * @param integer $best_id おすすめ商品ID
+ * @return void
+ */
+ public function delete($best_id)
+ {
+ $objDb = new SC_Helper_DB_Ex();
+ // ランク付きレコードの削除
+ $objDb->sfDeleteRankRecord('dtb_best_products', 'best_id', $best_id, TRUE);
+ }
+
+ /**
+ * 商品IDの配列からおすすめ商品を削除.
+ *
+ * @param array $productIDs 商品ID
+ * @return void
+ */
+ public function deleteByProductIDs($productIDs)
+ {
+ $objDb = new SC_Helper_DB_Ex();
+ $arrList = $this->getList();
+ foreach ($arrList as $recommend) {
+ if (in_array($recommend['product_id'], $productIDs)) {
+ $objDb->sfDeleteRankRecord('dtb_best_products', 'best_id', $recommend['best_id'], TRUE);
+ }
+ }
+ }
+
+ /**
+ * おすすめ商品の表示順をひとつ上げる.
+ *
+ * @param integer $best_id おすすめ商品ID
+ * @return void
+ */
+ public function rankUp($best_id)
+ {
+ $objDb = new SC_Helper_DB_Ex();
+ //おすすめはデータベースの登録が昇順なので、Modeを逆にする。
+ $objDb->sfRankDown('dtb_best_products', 'best_id', $best_id);
+ }
+
+ /**
+ * おすすめ商品の表示順をひとつ下げる.
+ *
+ * @param integer $best_id おすすめ商品ID
+ * @return void
+ */
+ public function rankDown($best_id)
+ {
+ $objDb = new SC_Helper_DB_Ex();
+ //おすすめはデータベースの登録が昇順なので、Modeを逆にする。
+ $objDb->sfRankUp('dtb_best_products', 'best_id', $best_id);
+ }
+}
変更: branches/version-2_12-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_Recommend.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_Recommend.php 2013-02-22 11:22:51 UTC (rev 22581)
+++ branches/version-2_12-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_Recommend.php 2013-02-26 00:09:44 UTC (rev 22582)
@@ -76,34 +76,28 @@
$this->lfInitParam($objFormParam);
$objFormParam->setParam($_POST);
$objFormParam->convParam();
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $objDb = new SC_Helper_DB_Ex();
+ $arrPost = $objFormParam->getHashArray();
+ $objRecommend = new SC_Helper_Recommend_Ex();
+
switch ($this->getMode()) {
- case 'down': //商品の並び替えをする。おすすめはデータベースの登録が昇順なので、Modeを逆にする。
- $arrRet = $objQuery->select('best_id', 'dtb_best_products', 'rank = ?', array($_POST['rank'])); //おすすめidの取得
- $best_id = $arrRet[0]['best_id'];
- $objDb->sfRankUp('dtb_best_products','best_id',$best_id);
- $arrPost = $objFormParam->getHashArray();
- $arrItems = $this->getRecommendProducts();
+ case 'down': //商品の並び替えをする。
+ $objRecommend->rankDown($arrPost['best_id']);
+ $arrItems = $this->getRecommendProducts($objRecommend);
break;
- case 'up': //商品の並び替えをする。おすすめのみデータベースの登録が昇順なので、Modeを逆にする。
- $arrRet = $objQuery->select('best_id', 'dtb_best_products', 'rank = ?', array($_POST['rank'])); //おすすめidの取得
- $best_id = $arrRet[0]['best_id'];
- $objDb->sfRankDown('dtb_best_products','best_id',$best_id);
- $arrPost = $objFormParam->getHashArray();
- $arrItems = $this->getRecommendProducts();
+ case 'up': //商品の並び替えをする。
+ $objRecommend->rankUp($arrPost['best_id']);
+ $arrItems = $this->getRecommendProducts($objRecommend);
break;
case 'regist': // 商品を登録する。
$this->arrErr = $this->lfCheckError($objFormParam);
- $arrPost = $objFormParam->getHashArray();
// 登録処理にエラーがあった場合は商品選択の時と同じ処理を行う。
if (SC_Utils_Ex::isBlank($this->arrErr)) {
$member_id = $_SESSION['member_id'];
- $this->insertRecommendProduct($arrPost,$member_id);
- $arrItems = $this->getRecommendProducts();
+ $this->insertRecommendProduct($arrPost,$member_id,$objRecommend);
+ $arrItems = $this->getRecommendProducts($objRecommend);
} else {
$arrItems = $this->setProducts($arrPost, $arrItems);
$this->checkRank = $arrPost['rank'];
@@ -112,10 +106,9 @@
break;
case 'delete': // 商品を削除する。
$this->arrErr = $this->lfCheckError($objFormParam);
- $arrPost = $objFormParam->getHashArray();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
- $this->deleteProduct($arrPost);
- $arrItems = $this->getRecommendProducts();
+ $this->deleteProduct($arrPost, $objRecommend);
+ $arrItems = $this->getRecommendProducts($objRecommend);
}
$this->tpl_onload = "window.alert('削除しました');";
break;
@@ -123,12 +116,12 @@
$this->arrErr = $this->lfCheckError($objFormParam);
$arrPost = $objFormParam->getHashArray();
if (SC_Utils_Ex::isBlank($this->arrErr['rank']) && SC_Utils_Ex::isBlank($this->arrErr['product_id'])) {
- $arrItems = $this->setProducts($arrPost, $this->getRecommendProducts());
+ $arrItems = $this->setProducts($arrPost, $this->getRecommendProducts($objRecommend));
$this->checkRank = $arrPost['rank'];
}
break;
default:
- $arrItems = $this->getRecommendProducts();
+ $arrItems = $this->getRecommendProducts($objRecommend);
break;
}
@@ -157,6 +150,7 @@
*/
function lfInitParam(&$objFormParam)
{
+ $objFormParam->addParam('おすすめ商品ID', 'best_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
$objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
$objFormParam->addParam('カテゴリID', 'category_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
$objFormParam->addParam('ランク', 'rank', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
@@ -177,20 +171,26 @@
/**
* 既に登録されている内容を取得する
+ * @param Object $objRecommend
* @return Array $arrReturnProducts データベースに登録されているおすすめ商品の配列
*/
- function getRecommendProducts()
+ function getRecommendProducts(SC_Helper_Recommend_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();
- $col = 'dtb_products.name,dtb_products.main_list_image,dtb_best_products.*,dtb_products.status';
- $table = 'dtb_best_products INNER JOIN dtb_products ON dtb_best_products.product_id = dtb_products.product_id';
- $where = 'dtb_best_products.del_flg = 0';
- $order = 'rank';
- $objQuery->setOrder($order);
- $arrProducts = $objQuery->select($col, $table, $where);
+ $arrProducts = $objProduct->getListByProductIds($objQuery, $product_ids);
$arrReturnProducts = array();
- foreach ($arrProducts as $data) {
+ 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;
@@ -200,12 +200,12 @@
* おすすめ商品の新規登録を行う。
* @param Array $arrPost POSTの値を格納した配列
* @param Integer $member_id 登録した管理者を示すID
+ * @param Object $objRecommend
*/
- function insertRecommendProduct($arrPost,$member_id)
+ function insertRecommendProduct($arrPost,$member_id, SC_Helper_Recommend_Ex &$objRecommend)
{
- $objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance();
// 古いおすすめ商品のデータを削除する。
- $this->deleteProduct($arrPost);
+ $this->deleteProduct($arrPost, $objRecommend);
$sqlval = array();
$sqlval['product_id'] = $arrPost['product_id'];
@@ -213,39 +213,41 @@
$sqlval['rank'] = $arrPost['rank'];
$sqlval['comment'] = $arrPost['comment'];
$sqlval['creator_id'] = $member_id;
- $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
- $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
- $sqlval['best_id'] = $objQuery->nextVal('dtb_best_products_best_id');
- $objQuery->insert('dtb_best_products', $sqlval);
+ $objRecommend->save($sqlval);
}
/**
* データを削除する
* @param Array $arrPost POSTの値を格納した配列
+ * @param Object $objRecommend
+ * @return void
*/
- function deleteProduct($arrPost)
+ function deleteProduct($arrPost, SC_Helper_Recommend_Ex &$objRecommend)
{
- $objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance();
- $table = 'dtb_best_products';
- $where = 'category_id = ? AND rank = ?';
- $arrWhereVal = array($arrPost['category_id'],$arrPost['rank']);
- $objQuery->delete($table, $where, $arrWhereVal);
+ if ($arrPost['best_id']) {
+ $target = $arrPost['best_id'];
+ } else {
+ $recommend = $objRecommend->getByRank($arrPost['rank']);
+ $target = $recommend['best_id'];
+ }
+ $objRecommend->delete($target);
}
/**
* 商品情報を取得する
* @param Integer $product_id 商品ID
- * @return Array $arrProduct 商品のデータを格納した配列
+ * @return Array $return 商品のデータを格納した配列
*/
function getProduct($product_id)
{
- $objQuery = $objQuery =& SC_Query_Ex::getSingletonInstance();
- $col = 'product_id,main_list_image,name';
- $table = 'dtb_products';
- $where = 'product_id = ? AND del_flg = 0';
- $arrWhereVal = array($product_id);
- $arrProduct = $objQuery->select($col, $table, $where, $arrWhereVal);
- return $arrProduct[0];
+ $objProduct = new SC_Product_Ex();
+ $arrProduct = $objProduct->getDetail($product_id);
+ $return = array(
+ 'product_id' => $arrProduct['product_id'],
+ 'main_list_image' => $arrProduct['main_list_image'],
+ 'name' => $arrProduct['name']
+ );
+ return $return;
}
/**
変更: branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products.php 2013-02-22 11:22:51 UTC (rev 22581)
+++ branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products.php 2013-02-26 00:09:44 UTC (rev 22582)
@@ -265,12 +265,20 @@
function doDelete($where, $arrParam = array())
{
$objQuery =& SC_Query_Ex::getSingletonInstance();
+ $arrRet = $objQuery->getCol('product_id', "dtb_products", $where, $arrParam);
+ $product_ids = array();
+ foreach ($arrRet as $value) {
+ $product_ids[] = $value['product_id'];
+ }
$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);
- $objQuery->delete('dtb_best_products', "product_id IN (SELECT product_id FROM dtb_products WHERE $where)", $arrParam);
+
+ $objRecomment = new SC_Helper_Recommend_Ex();
+ $objRecomment->deleteByProductIDs($product_ids);
+
$objQuery->update('dtb_products', $sqlval, $where, $arrParam);
$objQuery->commit();
}
変更: branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php 2013-02-22 11:22:51 UTC (rev 22581)
+++ branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php 2013-02-26 00:09:44 UTC (rev 22582)
@@ -93,42 +93,39 @@
*/
function lfGetRanking()
{
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $objProduct = new SC_Product_Ex();
+ $objRecommend = new SC_Helper_Recommend_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';
- if (NOSTOCK_HIDDEN) {
- $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))';
- }
- $objQuery->setOrder('T1.rank');
- $objQuery->setLimit(RECOMMEND_NUM);
- $arrBestProducts = $objQuery->select($col, $table, $where);
+ $arrRecommends = $objRecommend->getList(RECOMMEND_NUM);
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- if (count($arrBestProducts) > 0) {
+ $response = array();
+ if (count($arrRecommends) > 0) {
// 商品一覧を取得
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $objProduct = new SC_Product_Ex();
// where条件生成&セット
$arrProductId = array();
- $where = 'product_id IN (';
- foreach ($arrBestProducts as $key => $val) {
+ foreach ($arrRecommends as $key => $val) {
$arrProductId[] = $val['product_id'];
}
- // 取得
- $arrProductList = $objProduct->getListByProductIds($objQuery, $arrProductId);
+ $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId);
+
+ // 税込金額を設定する
+ SC_Product_Ex::setIncTaxToProducts($arrProducts);
+
// おすすめ商品情報にマージ
- foreach ($arrBestProducts as $key => $value) {
- $arrRow =& $arrBestProducts[$key];
- if (isset($arrProductList[$arrRow['product_id']])) {
- $arrRow = array_merge($arrRow, $arrProductList[$arrRow['product_id']]);
+ foreach ($arrRecommends as $key => $value) {
+ if (isset($arrProducts[$value['product_id']])) {
+ $product = $arrProducts[$value['product_id']];
+ if (!NOSTOCK_HIDDEN || ($product['status'] == 1 && ($product['stock_max'] >= 1 || $product['stock_unlimited_max'] == 1))) {
+ $response[] = array_merge($value, $arrProducts[$value['product_id']]);
+ }
} else {
// 削除済み商品は除外
- unset($arrBestProducts[$key]);
+ unset($arrRecommends[$key]);
}
}
}
- return $arrBestProducts;
+ return $response;
}
}
追加: branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Recommend_Ex.php
===================================================================
--- branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Recommend_Ex.php (rev 0)
+++ branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Recommend_Ex.php 2013-02-26 00:09:44 UTC (rev 22582)
@@ -0,0 +1,39 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+// {{{ requires
+require_once CLASS_REALDIR . 'helper/SC_Helper_Recommend.php';
+
+/**
+ * おすすめ商品を管理するヘルパークラス(拡張).
+ *
+ * LC_Helper_Recommend をカスタマイズする場合はこのクラスを編集する.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Recommend_Ex extends SC_Helper_Recommend
+{
+ //put your code here
+}
Svn-src-all メーリングリストの案内