27 public function sysSaveRelations(
Result $result)
29 parent::sysSaveRelations($result);
41 foreach ($this->entity->getFields() as $field)
46 if ($this->has($field->getName()))
48 $valueObject = $this->
get($field->getName());
50 if ($valueObject->state == State::RAW || $valueObject->state == State::CHANGED)
52 $valueObjects[$field->getName()] = $valueObject;
59 $columnName =
'PROPERTY_'.$field->getIblockElementProperty()->getId();
60 $valuesToDb[$columnName] =
null;
64 foreach ($valueObjects as $valueObject)
67 if ($valueObject->isChanged(
'VALUE'))
69 $columnName = $valueObject->entity->getField(
'VALUE')->getColumnName();
70 $valuesToDb[$columnName] = $valueObject->get(
'VALUE');
73 if ($valueObject->entity->hasField(
'DESCRIPTION') && $valueObject->isChanged(
'DESCRIPTION'))
75 $columnName = $valueObject->entity->getField(
'DESCRIPTION')->getColumnName();
76 $valuesToDb[$columnName] = $valueObject->get(
'DESCRIPTION');
80 if (!empty($valuesToDb))
83 $connection = $this->entity->getConnection();
84 $helper = $connection->getSqlHelper();
86 $tableName = $this->entity->getSingleValueTableName();
87 $update = $helper->prepareUpdate($tableName, $valuesToDb);
88 $where = $helper->prepareAssignment($tableName,
'IBLOCK_ELEMENT_ID', $this->getId());
90 $sql =
"UPDATE ".$helper->quote($tableName).
" SET ".$update[0].
" WHERE ".$where;
91 $connection->queryExecute($sql, $update[1]);
95 foreach ($valueObjects as $fieldName => $valueObject)
97 $currentValues = $valueObject->collectValues(Values::CURRENT);
99 foreach ($currentValues as $propFieldName => $propFieldValue)
101 $valueObject->sysSetActual($propFieldName, $propFieldValue);
104 $valueObject->sysPostSave();