Last active
September 8, 2015 14:54
-
-
Save kurozumi/78ff2937c686af2cfc6c to your computer and use it in GitHub Desktop.
【EC-CUBE2.13】更新日時順で商品一覧を表示する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* 商品一覧の表示 */ | |
/** | |
* @param SC_Product_Ex $objProduct | |
*/ | |
public function lfGetProductsList($searchCondition, $disp_number, $startno, &$objProduct) | |
{ | |
$objQuery =& SC_Query_Ex::getSingletonInstance(); | |
$arrOrderVal = array(); | |
// 表示順序 | |
switch ($this->orderby) { | |
// 販売価格が安い順 | |
case 'price': | |
$objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC'); | |
break; | |
// 新着順 | |
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(); | |
$arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId); | |
// 規格を設定 | |
$objProduct->setProductsClassByProductIds($arrProductId); | |
$arrProducts['productStatus'] = $objProduct->getProductStatus($arrProductId); | |
return $arrProducts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment