Simindey
6/14/2017 - 4:03 PM

Событие после CIBlockElement::SetPropertyValuesEx

Событие после CIBlockElement::SetPropertyValuesEx

<?

AddEventHandler("iblock", "OnAfterIBlockElementSetPropertyValuesEx", Array("HistoryChangesAvailability", "OnAfterIBlockElementSetPropertyValuesEx"));

CModule::IncludeModule("highloadblock");
use Bitrix\Highloadblock as HL;
use Bitrix\Main\Entity;

class HistoryChangesAvailability
{

    function OnAfterIBlockElementSetPropertyValuesEx($ELEMENT_ID, $IBLOCK_ID, $PROPERTY_VALUES, $FLAGS)
    {
			global $USER;
			$hlblock = HL\HighloadBlockTable::getById(6)->fetch();
			$entity = HL\HighloadBlockTable::compileEntity($hlblock);
			$entityClass = $entity->getDataClass();

			$arAdd = array(
							'UF_DATE' => date('d.m.Y H:i:s'),
							'UF_USER_ID' => $USER->GetID(),
							// 'UF_PROD_DEL' => $mark,
							'UF_PRODUCT_ID' => $ELEMENT_ID,
							// 'UF_PROP_DEL' => $mark,
							'UF_PROP_ID' => $PROPERTY_VALUES
					);
			$result = $entityClass::add($arAdd);
			// пишем лог для проверки
			AddMessage2Log("Запись с кодом ".$ELEMENT_ID."-".$IBLOCK_ID."-".$PROPERTY_VALUES."-".$FLAGS."добавлена.");

    }
}