コード例 #1
0
ファイル: Category.php プロジェクト: saiber/www
 /**
  * Removes category by ID and fixes data in parent categories
  * (updates activeProductCount and totalProductCount)
  *
  * @param int $recordID
  */
 public function delete()
 {
     ActiveRecordModel::beginTransaction();
     try {
         $activeProductCount = $this->activeProductCount->get();
         $totalProductCount = $this->totalProductCount->get();
         $availableProductCount = $this->availableProductCount->get();
         foreach ($this->getPathNodeSet(true) as $node) {
             $node->setFieldValue("activeProductCount", "activeProductCount - " . $activeProductCount);
             $node->setFieldValue("totalProductCount", "totalProductCount - " . $totalProductCount);
             $node->setFieldValue("availableProductCount", "availableProductCount - " . $availableProductCount);
             $node->save();
         }
         ActiveRecordModel::commit();
         parent::delete();
     } catch (Exception $e) {
         ActiveRecordModel::rollback();
         throw $e;
     }
 }