Permalink
Browse files

bug fix

  • Loading branch information...
1 parent 7b355cc commit a43a290e41f4b7a45834a4400398280fe2bd65a1 @kurozumi committed Jan 8, 2017
Showing with 26 additions and 51 deletions.
  1. +26 −51 OrderBy.php
View
@@ -33,6 +33,7 @@
*/
class OrderBy extends SC_Plugin_Base
{
+
/**
* コンストラクタ
*
@@ -42,8 +43,9 @@ class OrderBy extends SC_Plugin_Base
public function __construct(array $arrSelfInfo)
{
// プラグインを有効化したときの初期設定をココに追加する
- if($arrSelfInfo["enable"] == 1) {}
-
+ if ($arrSelfInfo["enable"] == 1) {
+
+ }
}
/**
@@ -60,7 +62,7 @@ public function install($arrPlugin, $objPluginInstaller = null)
$src_dir = PLUGIN_UPLOAD_REALDIR . "{$arrPlugin["plugin_code"]}/html/admin/";
$dest_dir = HTML_REALDIR . ADMIN_DIR;
SC_Utils::copyDirectory($src_dir, $dest_dir);
-
+
// テンプレートを配置。
$src_dir = PLUGIN_UPLOAD_REALDIR . "{$arrPlugin["plugin_code"]}/data/Smarty/templates/";
$dest_dir = SMARTY_TEMPLATES_REALDIR;
@@ -81,7 +83,7 @@ public function uninstall($arrPlugin, $objPluginInstaller = null)
$target_dir = HTML_REALDIR . ADMIN_DIR;
$source_dir = PLUGIN_UPLOAD_REALDIR . "{$arrPlugin["plugin_code"]}/html/admin/";
self::deleteDirectory($target_dir, $source_dir);
-
+
// テンプレートを削除。
$target_dir = SMARTY_TEMPLATES_REALDIR;
$source_dir = PLUGIN_UPLOAD_REALDIR . "{$arrPlugin["plugin_code"]}/data/Smarty/templates/";
@@ -98,6 +100,7 @@ public function uninstall($arrPlugin, $objPluginInstaller = null)
*/
public function enable($arrPlugin, $objPluginInstaller = null)
{
+
}
/**
@@ -110,6 +113,7 @@ public function enable($arrPlugin, $objPluginInstaller = null)
*/
public function disable($arrPlugin, $objPluginInstaller = null)
{
+
}
/**
@@ -121,7 +125,6 @@ public function register(SC_Helper_Plugin $objHelperPlugin, $priority)
{
$objHelperPlugin->addAction("prefilterTransform", array(&$this, "prefilterTransform"), $priority);
$objHelperPlugin->addAction("LC_Page_Products_List_action_after", array(&$this, "products_list_action_after"), $priority);
-
}
/**
@@ -130,8 +133,11 @@ public function register(SC_Helper_Plugin $objHelperPlugin, $priority)
*/
function products_list_action_after(LC_Page_EX $objPage)
{
+ if ($objPage->orderby != "update")
+ return;
+
$objProduct = new SC_Product_Ex();
-
+
// パラメーター管理クラス
$objFormParam = new SC_FormParam_Ex();
@@ -143,13 +149,13 @@ function products_list_action_after(LC_Page_EX $objPage)
// 入力値の変換
$objFormParam->convParam();
-
+
// 商品一覧データの取得
$arrSearchCondition = $objPage->lfGetSearchCondition($objPage->arrSearchData);
- $objPage->tpl_linemax = $objPage->lfGetProductAllNum($arrSearchCondition);
-
- $objPage->objNavi = new SC_PageNavi_Ex($objPage->tpl_pageno, $objPage->tpl_linemax, $objPage->disp_number, 'eccube.movePage', NAVI_PMAX, $urlParam, SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE);
- $objPage->arrProducts = $this->lfGetProductsList($arrSearchCondition, $objPage->disp_number, $objPage->objNavi->start_row, $objProduct, $objPage);
+ $objPage->tpl_linemax = $objPage->lfGetProductAllNum($arrSearchCondition);
+
+ $objPage->objNavi = new SC_PageNavi_Ex($objPage->tpl_pageno, $objPage->tpl_linemax, $objPage->disp_number, 'eccube.movePage', NAVI_PMAX, $urlParam, SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE);
+ $objPage->arrProducts = $this->lfGetProductsList($arrSearchCondition, $objPage->disp_number, $objPage->objNavi->start_row, $objProduct);
switch ($objPage->getMode()) {
case 'json':
@@ -160,60 +166,29 @@ function products_list_action_after(LC_Page_EX $objPage)
$objPage->doDefault($objProduct, $objFormParam);
break;
}
-
}
-
+
/**
* 商品一覧の表示
*
* @param SC_Product_Ex $objProduct
*/
- public function lfGetProductsList($searchCondition, $disp_number, $startno, &$objProduct, LC_Page_EX $objPage)
+ public function lfGetProductsList($searchCondition, $disp_number, $startno, &$objProduct)
{
- $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $objQuery = & SC_Query_Ex::getSingletonInstance();
$arrOrderVal = array();
- // 表示順序
- switch ($objPage->orderby) {
- // 販売価格が安い順
- case 'price':
- $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC');
- break;
+ $objProduct->setProductsOrder('update_date', 'dtb_products', 'DESC');
- // 新着順
- case 'date':
- $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC');
- break;
-
- // 更新順
- case 'update':
- $objProduct->setProductsOrder('update_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();
+ $objQuery = & SC_Query_Ex::getSingletonInstance();
$arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId);
// 規格を設定
@@ -256,24 +231,24 @@ public function prefilterTransform(&$source, LC_Page_Ex $objPage, $filename)
break;
}
$source = $objTransform->getHTML();
-
}
-
+
/**
* 指定されたパスを比較して再帰的に削除します。
*
* @param string $target_dir 削除対象のディレクトリ
* @param string $source_dir 比較対象のディレクトリ
*/
- public static function deleteDirectory($target_dir, $source_dir) {
+ public static function deleteDirectory($target_dir, $source_dir)
+ {
$dir = opendir($source_dir);
while ($name = readdir($dir)) {
if ($name == '.' || $name == '..') {
continue;
}
$target_path = $target_dir . '/' . $name;
$source_path = $source_dir . '/' . $name;
-
+
if (is_file($source_path)) {
if (is_file($target_path)) {
unlink($target_path);

0 comments on commit a43a290

Please sign in to comment.