- Timestamp:
- 2014/05/29 13:59:35 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/class/helper/SC_Helper_DB.php
r23457 r23458 371 371 372 372 /** 373 * カテゴリツリーの取得を複数カテゴリで行う.374 *375 * @param integer $product_id 商品ID376 * @param bool $count_check 登録商品数のチェックを行う場合 true377 * @return array カテゴリツリーの配列378 */379 public static function sfGetMultiCatTree($product_id, $count_check = false)380 {381 $objQuery =& SC_Query_Ex::getSingletonInstance();382 $col = '';383 $col .= ' cat.category_id,';384 $col .= ' cat.category_name,';385 $col .= ' cat.parent_category_id,';386 $col .= ' cat.level,';387 $col .= ' cat.rank,';388 $col .= ' cat.creator_id,';389 $col .= ' cat.create_date,';390 $col .= ' cat.update_date,';391 $col .= ' cat.del_flg, ';392 $col .= ' ttl.product_count';393 $from = 'dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id';394 // 登録商品数のチェック395 if ($count_check) {396 $where = 'del_flg = 0 AND product_count > 0';397 } else {398 $where = 'del_flg = 0';399 }400 $objQuery->setOption('ORDER BY rank DESC');401 $arrRet = $objQuery->select($col, $from, $where);402 403 $arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId($product_id);404 405 $arrCatTree = array();406 foreach ($arrCategory_id as $pkey => $parent_category_id) {407 $arrParentID = SC_Helper_DB_Ex::sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id);408 409 foreach ($arrParentID as $pid) {410 foreach ($arrRet as $key => $array) {411 if ($array['category_id'] == $pid) {412 $arrCatTree[$pkey][] = $arrRet[$key];413 break;414 }415 }416 }417 }418 419 return $arrCatTree;420 }421 422 /**423 373 * 親カテゴリを連結した文字列を取得する. 424 374 * … … 564 514 * 選択中の商品のカテゴリを取得する. 565 515 * 566 * @param integer $product_id プロダクトID 567 * @param integer $category_id カテゴリID 568 * @return array 選択中の商品のカテゴリIDの配列 516 * @param int $product_id プロダクトID 517 * @param int $category_id カテゴリID 518 * @param bool $closed 非表示の商品を含む場合はtrue 519 * @return array 選択中の商品のカテゴリIDの配列 569 520 * 570 521 */ 571 522 public function sfGetCategoryId($product_id, $category_id = 0, $closed = false) 572 523 { 573 if ($closed) {574 $status = '';575 } else {576 $status = 'status = 1';577 }578 524 $category_id = (int) $category_id; 579 525 $product_id = (int) $product_id; 580 if (SC_Utils_Ex::sfIsInt($category_id) && $category_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_category','category_id', $category_id)) {526 if (SC_Utils_Ex::sfIsInt($category_id) && $category_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_category','category_id', array($category_id))) { 581 527 $category_id = array($category_id); 582 } elseif (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_products','product_id', $product_id, $status)) {583 $objQuery =& SC_Query_Ex::getSingletonInstance();584 $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', array($product_id));585 528 } else { 586 // 不正な場合は、空の配列を返す。587 $category_id = array();529 $objProduct = new SC_Product_Ex(); 530 $category_id = $objProduct->getCategoryIds($product_id, $closed); 588 531 } 589 532
Note: See TracChangeset
for help on using the changeset viewer.