/** * * @todo fix potential bug: when using $this->load() in method, it might * overwrite the data that was set during runtime */ protected function update() { ActiveRecordModel::beginTransaction(); try { parent::update(); $activeProductCount = $this->activeProductCount->get(); if ($this->isEnabled->isModified()) { if ($this->isEnabled()) { $activeProductCountUpdateStr = "activeProductCount + " . $activeProductCount; } else { $activeProductCountUpdateStr = "activeProductCount - " . $activeProductCount; } $pathNodes = $this->getPathNodeSet(true); foreach ($pathNodes as $node) { if ($node->getID() != $this->getID()) { $f = new ARUpdateFilter(); $f->addModifier('activeProductCount', new ARExpressionHandle($activeProductCountUpdateStr)); $node->updateRecord($f); } } } ActiveRecordModel::commit(); } catch (Exception $e) { ActiveRecordModel::rollback(); throw $e; } }