A
A
Anumik2016-09-19 10:17:41
1C-Bitrix
Anumik, 2016-09-19 10:17:41

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

2 answer(s)
N
Nikita, 2016-09-19
@Rema1ns

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;
        }
    }
}
?>

Well, for the update, you also need to issue

F
firm, 2016-09-19
@firm

>> 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 question

Ask a Question

731 491 924 answers to any question