public function beforeSaveConfig(Am_Config $before, Am_Config $after) { $arr = $after->getArray(); if (empty($arr['aff_comm'])) { return; } $this->rule = Am_Di::getInstance()->affCommissionRuleTable->findFirstByType(AffCommissionRule::TYPE_GLOBAL_1); if (empty($this->rule)) { $this->rule = Am_Di::getInstance()->affCommissionRuleTable->createRecord(); $this->rule->type = AffCommissionRule::TYPE_GLOBAL_1; $this->rule->title = "Default Commmission"; } foreach ($arr['aff_comm'] as $aa) { foreach ($aa as $k => $v) { $this->rule->set($k, $v); } } unset($arr['aff_comm']); $after->setArray($arr); }