Ignore:
Timestamp:
2014/05/20 17:56:50 (12 years ago)
Author:
pineray
Message:

#2554 カテゴリーの削除処理を SC_Helper_Category へ移動

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_Category.php

    r23124 r23435  
    6767    public function action() 
    6868    { 
    69         $objDb      = new SC_Helper_DB_Ex(); 
    7069        $objFormParam = new SC_FormParam_Ex(); 
    7170        $objCategory = new SC_Helper_Category_Ex(); 
     
    8786            // カテゴリ削除 
    8887            case 'delete': 
    89                 $this->doDelete($objFormParam, $objDb); 
     88                $this->doDelete($objFormParam); 
    9089                break; 
    9190            // 表示順を上へ 
     
    194193     * 
    195194     * @param  SC_FormParam $objFormParam 
    196      * @param  SC_Helper_Db $objDb 
    197      * @return void 
    198      */ 
    199     public function doDelete(&$objFormParam, &$objDb) 
    200     { 
     195     * @return void 
     196     */ 
     197    public function doDelete(&$objFormParam) 
     198    { 
     199        $objCategory = new SC_Helper_Category_Ex(false); 
    201200        $category_id = $objFormParam->getValue('category_id'); 
    202         $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    203201 
    204202        // 子カテゴリのチェック 
    205         $where = 'parent_category_id = ? AND del_flg = 0'; 
    206         $exists = $objQuery->exists('dtb_category', $where, array($category_id)); 
    207         if ($exists) { 
     203        $arrBranch = $objCategory->getTreeBranch($category_id); 
     204        if (count($arrBranch) > 0) { 
    208205            $this->arrErr['category_name'] = '※ 子カテゴリが存在するため削除できません。<br/>'; 
    209  
    210206            return; 
    211207        } 
    212208        // 登録商品のチェック 
    213         $table = 'dtb_product_categories AS T1 LEFT JOIN dtb_products AS T2 ON T1.product_id = T2.product_id'; 
    214         $where = 'T1.category_id = ? AND T2.del_flg = 0'; 
    215         $exists = $objQuery->exists($table, $where, array($category_id)); 
    216         if ($exists) { 
     209        $arrCategory = $objCategory->get($category_id); 
     210        if ($arrCategory['product_count'] > 0) { 
    217211            $this->arrErr['category_name'] = '※ カテゴリ内に商品が存在するため削除できません。<br/>'; 
    218  
    219212            return; 
    220213        } 
    221214 
    222215        // ランク付きレコードの削除(※処理負荷を考慮してレコードごと削除する。) 
    223         $objDb->sfDeleteRankRecord('dtb_category', 'category_id', $category_id, '', true); 
     216        $objCategory->delete($category_id); 
    224217    } 
    225218 
Note: See TracChangeset for help on using the changeset viewer.