How to write a handler for 1C-Bitrix?

Good day
You must write a handler that upon import of the goods will check one custom property and use it to change the root partition
i.e. from the discharge
all products -> section 1 -> section 2 -> element whose property = men's
we put it on the base Bitrix as
male -> section 1 -> section 2 -> element
Maybe someone will be able to tell? Study only, with the handler a second time faced
July 4th 19 at 23:20
2 answers
July 4th 19 at 23:22
There are events before you add \ change elemet.

<?
// file /bitrix/php_interface/init.php
// register a handler
AddEventHandler("iblock", "OnBeforeIBlockElementAdd", Array("MyClass", "OnBeforeIBlockElementAddHandler"));

class MyClass
{
 // create event handler "OnBeforeIBlockElementAdd"
 OnBeforeIBlockElementAddHandler function(&$arFields)
{
if(strlen($arFields["CODE"])<=0)
{
 global $APPLICATION;
 $APPLICATION--->throwException("Enter character code.");
 return false;
}
}
}
?>


Well for update as it is necessary to execute
to update registers OnBeforeIBlockElementUpdate - Bell_Anders commented on July 4th 19 at 23:25
and the file init Tikrit output, therefore, write the dumps to the buffet, then to a file. Or yuzaete logs Bitrix - Bell_Anders commented on July 4th 19 at 23:28
July 4th 19 at 23:24
>> will test one custom property and use it to change the root partition
If you're going to do it in men's products may fall, and other "not for men" products.

It is easier initially to create the desired directory structure, and then for specific attributes to bind them to the appropriate directories.

Find more questions by tags 1C-Bitrix