Index: branches/comu-ver2/html/user_data/plugins/recommend/classes/LC_Page_FrontParts_Bloc_Recommend.php
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/classes/LC_Page_FrontParts_Bloc_Recommend.php	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/classes/LC_Page_FrontParts_Bloc_Recommend.php	(revision 18371)
@@ -0,0 +1,113 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2009 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.
+ */
+
+require_once CLASS_PATH . 'pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php';
+
+/**
+ * こんな商品も買っていますプラグインを制御するクラス
+ *
+ * @package Page
+ * @author Seasoft 塚田将久
+ * @version $Id:$
+ */
+class LC_Page_FrontParts_Bloc_Recommend extends LC_Page_FrontParts_Bloc {
+
+    /** プラグイン情報配列 (呼び出し元でセットする) */
+    var $arrPluginInfo;
+
+    /** 取得する上限数 */
+    var $max = 4;
+
+    var $arrRecommendProducts = array();
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = $this->arrPluginInfo['fullpath'] . 'tpl/bloc.tpl';
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objSubView = new SC_SiteView(false);
+
+        $this->arrRecommendProducts = $this->lfGetRecommendProducts($_REQUEST['product_id']);
+
+        $objSubView->assignobj($this);
+        $objSubView->display($this->tpl_mainpage);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function lfGetRecommendProducts($product_id) {
+
+        $objQuery = new SC_Query();
+        $cols = '*, (SELECT COUNT(*) FROM dtb_order_detail WHERE product_id = allcls.product_id) AS cnt';
+        $from = 'vw_products_allclass AS allcls';
+        $where = <<< __EOS__
+            del_flg = 0
+            AND status = 1
+            AND product_id IN (
+                SELECT product_id
+                FROM
+                    dtb_order_detail
+                    INNER JOIN dtb_order
+                        ON dtb_order_detail.order_id = dtb_order.order_id
+                WHERE 0=0
+                    AND dtb_order.del_flg = 0
+                    AND dtb_order.order_id IN (
+                        SELECT order_id
+                        FROM dtb_order_detail
+                        WHERE 0=0
+                            AND product_id = ?
+                    )
+                    AND dtb_order_detail.product_id <> ?
+            )
+__EOS__;
+        $objQuery->setorder('cnt DESC, RANDOM()');
+        $objQuery->setlimit($this->max);
+        $recommendProducts = $objQuery->select($cols, $from, $where, array($product_id, $product_id));
+
+        return $recommendProducts;
+    }
+}
+?>
Index: branches/comu-ver2/html/user_data/plugins/recommend/classes/LC_Page_Admin_Plugin_Recommend.php
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/classes/LC_Page_Admin_Plugin_Recommend.php	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/classes/LC_Page_Admin_Plugin_Recommend.php	(revision 18371)
@@ -0,0 +1,74 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2009 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.
+ */
+
+require_once CLASS_PATH . "pages/LC_Page.php";
+
+/**
+ * こんな商品も買っていますプラグインの管理画面を制御するクラス.
+ *
+ * @package Page
+ * @author Seasoft 塚田将久
+ * @version $Id:$
+ */
+class LC_Page_Admin_Plugin_Recommend extends LC_Page {
+
+    /** プラグイン情報配列 (呼び出し元でセットする) */
+    var $arrPluginInfo;
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+        $this->tpl_mainpage = $this->arrPluginInfo['fullpath'] . 'tpl/admin/index.tpl';
+        $this->tpl_mainno   = 'plugin';
+        $this->tpl_subno    = $this->arrPluginInfo['path'];
+        $this->tpl_subtitle = "プラグイン「{$this->arrPluginInfo['name']}」の設定";
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        // 認証可否の判定
+        SC_Utils_Ex::sfIsSuccess(new SC_Session());
+
+        $objView = new SC_AdminView();
+        $objView->assignobj($this);
+        $objView->display(MAIN_FRAME);
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+}
+?>
Index: branches/comu-ver2/html/user_data/plugins/recommend/plugin_info.php
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/plugin_info.php	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/plugin_info.php	(revision 18371)
@@ -0,0 +1,8 @@
+<?php
+$arrPluginInfo = SC_Utils_Ex::sfMakePluginInfoArray(__FILE__);
+
+$arrPluginInfo['name']      = 'こんな商品も買っています';
+$arrPluginInfo['version']   = ECCUBE_VERSION . ' 付属';
+$arrPluginInfo['auther']    = 'EC-CUBE 標準添付 (サンプル)';
+
+return $arrPluginInfo;
Index: branches/comu-ver2/html/user_data/plugins/recommend/sql/install.sql
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/sql/install.sql	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/sql/install.sql	(revision 18371)
@@ -0,0 +1,1 @@
+INSERT INTO dtb_bloc (bloc_name, tpl_path, filename, php_path, del_flg) VALUES ('こんな商品も買っています', 'user_data/plugins/recommend/tpl/bloc.tpl', 'recommend', 'user_data/plugins/recommend/bloc.php', 1);
Index: branches/comu-ver2/html/user_data/plugins/recommend/sql/uninstall.sql
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/sql/uninstall.sql	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/sql/uninstall.sql	(revision 18371)
@@ -0,0 +1,2 @@
+DELETE FROM dtb_blocposition WHERE bloc_id = (SELECT bloc_id FROM dtb_bloc WHERE filename = 'recommend');
+DELETE FROM dtb_bloc WHERE filename = 'recommend';
Index: branches/comu-ver2/html/user_data/plugins/recommend/tpl/admin/index.tpl
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/tpl/admin/index.tpl	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/tpl/admin/index.tpl	(revision 18371)
@@ -0,0 +1,3 @@
+<div>
+    このプラグインには、設定項目がありません。
+</div>
Index: branches/comu-ver2/html/user_data/plugins/recommend/tpl/bloc.tpl
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/tpl/bloc.tpl	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/tpl/bloc.tpl	(revision 18371)
@@ -0,0 +1,40 @@
+<!--▼こんな商品も買っています-->
+<!--{foreach from="$arrRecommendProducts" item="arrProduct" name="arrProduct"}-->
+    <!--{if $smarty.foreach.arrProduct.first}-->
+        <div id="undercolumn" class="product product_detail" style="margin-top: 0;"><!--{* FIXME detail.tpl と id 重複 *}-->
+            <div id="whoboughtarea">
+                <h2><img src="<!--{$smarty.const.PLUGIN_URL|escape}--><!--{$arrPluginInfo.path}-->/img/title_recommend.png" width="580" height="30" alt="この商品を買った人はこんな商品も買っています" /></h2>
+                <div class="whoboughtblock">
+    <!--{/if}-->
+
+
+    <!--{if ($smarty.section.cnt.index % 2) == 0}-->
+        <!--{if $arrProduct.product_id}-->
+            <div class="whoboughtleft"><!--{* XXX whoboughtleft は本来左列用なので、動作に不具合があるかもしれない。 *}-->
+                
+                <a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrProduct.product_id}-->">
+                    <img src="<!--{$smarty.const.SITE_URL}-->resize_image.php?image=<!--{$arrProduct.main_list_image|sfNoImageMainList|escape}-->&amp;width=65&amp;height=65" alt="<!--{$arrProduct.name|escape}-->" /></a>
+
+                <!--{assign var=price02_min value=`$arrProduct.price02_min`}-->
+                <!--{assign var=price02_max value=`$arrProduct.price02_max`}-->
+                <h3><a href="<!--{$smarty.const.DETAIL_P_HTML}--><!--{$arrProduct.product_id}-->"><!--{$arrProduct.name|escape}--></a></h3>
+
+                <p class="sale_price"><!--{$smarty.const.SALE_PRICE_TITLE}--><span class="mini">(税込)</span>：<span class="price">
+                    <!--{if $price02_min == $price02_max}-->
+                        <!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
+                    <!--{else}-->
+                        <!--{$price02_min|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->～<!--{$price02_max|sfPreTax:$arrSiteInfo.tax:$arrSiteInfo.tax_rule|number_format}-->
+                    <!--{/if}-->円</span></p>
+                <p class="mini"><!--{$arrProduct.comment|escape|nl2br}--></p>
+            </div>
+        <!--{/if}-->
+    <!--{/if}-->
+
+
+    <!--{if $smarty.foreach.arrProduct.last}-->
+                </div>
+            </div>
+        </div>
+    <!--{/if}-->
+<!--{/foreach}-->
+<!--▲こんな商品も買っています-->
Index: branches/comu-ver2/html/user_data/plugins/recommend/require.php
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/require.php	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/require.php	(revision 18371)
@@ -0,0 +1,5 @@
+<?php
+/*
+ * EC-CUBE 本体で, このプラグインの関数を使用したい場合は, ここで require する
+ */
+
Index: branches/comu-ver2/html/user_data/plugins/recommend/bloc.php
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/bloc.php	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/bloc.php	(revision 18371)
@@ -0,0 +1,30 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2009 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.
+ */
+$arrPluginInfo = SC_Utils_Ex::sfLoadPluginInfo(dirname(__FILE__) . '/plugin_info.php');
+require_once $arrPluginInfo['fullpath'] . 'classes/LC_Page_FrontParts_Bloc_Recommend.php';
+
+$objPage = new LC_Page_FrontParts_Bloc_Recommend();
+$objPage->arrPluginInfo = $arrPluginInfo;
+register_shutdown_function(array($objPage, 'destroy'));
+$objPage->init();
+$objPage->process();
Index: branches/comu-ver2/html/user_data/plugins/recommend/admin/index.php
===================================================================
--- branches/comu-ver2/html/user_data/plugins/recommend/admin/index.php	(revision 18371)
+++ branches/comu-ver2/html/user_data/plugins/recommend/admin/index.php	(revision 18371)
@@ -0,0 +1,32 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2009 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.
+ */
+require_once '../../../../admin/require.php';
+$arrPluginInfo = SC_Utils_Ex::sfLoadPluginInfo('../plugin_info.php');
+require_once $arrPluginInfo['fullpath'] . 'classes/LC_Page_Admin_Plugin_Recommend.php';
+
+$objPage = new LC_Page_Admin_Plugin_Recommend();
+$objPage->arrPluginInfo = $arrPluginInfo;
+register_shutdown_function(array($objPage, 'destroy'));
+$objPage->init();
+$objPage->process();
+?>
