Here is the answer to the question:
\Bitrix\Main\EventManager::getInstance()-> addEventHandler("sale", "OnSaleOrderBeforeSaved", "OnSHandler"); function OnSHandler(Bitrix\Main\Event $event) { $order = $event->getParameter("ENTITY"); $propertyCollection = $order->getPropertyCollection(); foreach ($propertyCollection->getGroups() as $group) { foreach ($propertyCollection->getGroupProperties($group['ID']) as $property) { $p = $property->getProperty(); if (15 == $p["ID"]) { $family = $property->getField("VALUE"); } if (19 == $p["ID"]) { $name = $property->getField("VALUE"); } if ("PRIVATE_PERSON" == $p["CODE"]) { $property->setValue($name . ' ' . $family); } } } }
I publish with the purpose of CodeReview. Support answered:
QUOTATION You do not need to write to the database in this event. You just need to take the collection of the properties of the $ order object and add your own data to it, or modify the existing ones. The system itself will then save everything to the database:
$ propertyCollection = $ order-> getPropertyCollection ();
$ propertyCollection = $ order-> getPropertyCollection ();
foreach ($ propertyCollection-> getGroups () as $ group) {
foreach ($ propertyCollection-> getGroupProperties ($ group ['ID']) as $ property) {
$ p = $ property-> getProperty (); if ($ p ["CODE"] == "CONTACT_PERSON") $ property-> setValue ("VASYA");
}}
Sincerely, Leading Specialist of the Technical Support Department Shestopalov Lev
In doing so, we used the OnSaleOrderBeforeSaved event.
To finish it helped me:
https://mrcappuccino.ru/blog/post/work-with-basket-bitrix-d7