/** * @param $name * @param $value * @return Result * @throws Main\ArgumentOutOfRangeException * @throws Main\NotImplementedException * @throws \Exception */ public function setField($name, $value) { if ($name == "PAY_SYSTEM_ID") { if (intval($value) > 0 && !PaySystemService::isExist($value)) { $result = new Result(); $result->addError(new ResultError(Loc::getMessage('SALE_PAYMENT_WRONG_PAYMENT_SERVICE'), 'SALE_PAYMENT_WRONG_PAYMENT_SERVICE')); return $result; } /** @var PaymentCollection $paymentCollection */ if (!($paymentCollection = $this->getCollection())) { throw new Main\ObjectNotFoundException('Entity "PaymentCollection" not found'); } if (count($paymentCollection) == 1) { /** @var Order $order */ if ($order = $paymentCollection->getOrder()) { if (strval($order->getField('PAY_SYSTEM_ID')) == '') { $order->setFieldNoDemand('PAY_SYSTEM_ID', intval($value)); } } } } return parent::setField($name, $value); }