public function onCouponBeforeUpdate(Am_Event $event) { $coupon = $event->getCoupon(); if (!$coupon->aff_id) { $coupon->aff_id = null; } if (!is_numeric($coupon->aff_id)) { $user = $this->getDi()->userTable->findFirstByLogin($coupon->aff_id); $coupon->aff_id = $user ? $user->pk() : null; } }