Пример #1
0
 /**
  * 親カテゴリーIDの配列を取得.
  *
  * @param  integer $category_id 起点のカテゴリーID
  * @param  boolean $id_only     IDだけの配列を返す場合はtrue
  * @return array
  */
 public function getTreeTrail($category_id, $id_only = TRUE)
 {
     $arrCategory = $this->getList(TRUE);
     $arrTrailID = Utils::getTreeTrail($category_id, 'category_id', 'parent_category_id', $arrCategory, TRUE, 0, $id_only);
     return $arrTrailID;
 }
Пример #2
0
 /**
  * カテゴリツリーの取得を行う.
  *
  * @param  integer $parent_category_id 親カテゴリID
  * @param  bool    $count_check        登録商品数のチェックを行う場合 true
  * @return array   カテゴリツリーの配列
  */
 public function getCatTree($parent_category_id, $count_check = false)
 {
     /* @var $objQuery Query */
     $objQuery = Application::alias('eccube.query');
     $col = '';
     $col .= ' cat.category_id,';
     $col .= ' cat.category_name,';
     $col .= ' cat.parent_category_id,';
     $col .= ' cat.level,';
     $col .= ' cat.rank,';
     $col .= ' cat.creator_id,';
     $col .= ' cat.create_date,';
     $col .= ' cat.update_date,';
     $col .= ' cat.del_flg, ';
     $col .= ' ttl.product_count';
     $from = 'dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id';
     // 登録商品数のチェック
     if ($count_check) {
         $where = 'del_flg = 0 AND product_count > 0';
     } else {
         $where = 'del_flg = 0';
     }
     $objQuery->setOption('ORDER BY rank DESC');
     $arrRet = $objQuery->select($col, $from, $where);
     $arrParentID = Utils::getTreeTrail($parent_category_id, 'category_id', 'parent_category_id', $arrRet);
     foreach ($arrRet as $key => $array) {
         foreach ($arrParentID as $val) {
             if ($array['category_id'] == $val) {
                 $arrRet[$key]['display'] = 1;
                 break;
             }
         }
     }
     return $arrRet;
 }