Answer the question
In order to leave comments, you need to log in
How to write a handler for 1C-Bitrix?
Good day. It is
necessary to write a handler that, when importing goods, will check one custom property and change the root section using it
. we get all the goods from the unloading
-> section 1 -> section 2 -> element whose property = male
we enter it into the Bitrix database as
male -> section 1 -> section 2 -> element
Can someone tell me? I'm only learning, I ran into handlers for the second time
Answer the question
In order to leave comments, you need to log in
There are events before adding \ changing an element.
<?
// файл /bitrix/php_interface/init.php
// регистрируем обработчик
AddEventHandler("iblock", "OnBeforeIBlockElementAdd", Array("MyClass", "OnBeforeIBlockElementAddHandler"));
class MyClass
{
// создаем обработчик события "OnBeforeIBlockElementAdd"
function OnBeforeIBlockElementAddHandler(&$arFields)
{
if(strlen($arFields["CODE"])<=0)
{
global $APPLICATION;
$APPLICATION->throwException("Введите символьный код.");
return false;
}
}
}
?>
>> will check one custom property and change the root section based on it.
If you do this, then other "non-male" products can get into men's products.
It's easier to initially create the desired directory structure, and then bind them to the appropriate directories using certain attributes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question