Working with Bitrix events
Работа с событиями Битрикс

All English-language materials have been translated fully automatically using the Google service

Interception of adding an infoblock element

  // We intercept the creation of infoblock elements after filling out the forms to add them to Bitrix24
AddEventHandler ("iblock", "OnAfterIBlockElementAdd", Array ("OnAfterIBlockElementAddClass", "OnAfterIBlockElementAddHandler"));

class OnAfterIBlockElementAddClass
    function OnAfterIBlockElementAddHandler (& $ arFields)
        if (($ arFields ["IBLOCK_ID"] == 15) {// We work with an infoblock with id = 15

// Your code is here


The $ arFields array contains something like the following:

  array (
  'IBLOCK_ID' => 13,
  'ACTIVE' => 'Y',
  'NAME' => 'Name of information block element',
  array (
    'bxajaxid' => '2b203f84d8a89c2',
    'AJAX_CALL' => 'Y',
    'sessid' => '8fa4b79357bcd2a',
    'PHONE' => '899300000000',
    'EMAIL' => '',
    'FIO' => 'Pround',
    'COMMENT' =>
    array (
      'VALUE' =>
      array (
        'TEXT' => 'User comment',
        'TYPE' => 'html',
    'form_submit' => 'Add',
    'PHPSESSID' => '2fd5f8352a64d5',
    'BITRIX_SM_UIDL' => 'admin',
    'BITRIX_SM_LOGIN' => 'admin',
    'BITRIX_SM_DSC' => '44',
  'SEARCHABLE_CONTENT' => 'Name of information block element',
  'CREATED_BY' => 1,
  'MODIFIED_BY' => 1,
  '~ DATE_CREATE' => 'now ()',
  '~ TIMESTAMP_X' => 'now ()',
  'XML_ID' => 3487,
  'ID' => 3487,
  'RESULT' => 3487,

Intercept emails

Intercepting a message just before sending

  AddEventHandler ('main', 'OnBeforeEventSend', Array ("OnBeforeEventSendClass", "my_OnBeforeEventSend"));
class OnBeforeEventSendClass
    function my_OnBeforeEventSend ($ arFields, $ arTemplate)
        // get the message

// Intercept the generation of a mail event with the ability to cancel it

  AddEventHandler ("main", "OnBeforeEventAdd", array ("OnBeforeEventAddClass", "OnBeforeEventAddHandler"));
class OnBeforeEventAddClass {
    function OnBeforeEventAddHandler (& $ event, & $ lid, & $ arFields, & $ message_id, & $ files) {


Exchange with 1C

Handler for resetting the stock of goods

  AddEventHandler ("catalog", "OnSuccessCatalogImport1C", "DSOnSuccessCatalogImport1C");
function DSOnSuccessCatalogImport1C ()

    if (CModule :: IncludeModule ("catalog"))
        $ db_res = CCatalogProduct :: GetList (array ("QUANTITY" => "DESC"), array ("> QUANTITY_RESERVED" => 0), false, false);
        while ($ ar_res = $ db_res-> Fetch ())
            if (! CCatalogProduct :: Update ($ ar_res ["ID"], array ("QUANTITY_RESERVED" => 0))) {
                AddMessage2Log ("Update failed". $ Ar_res ["ID"]);
            } // endif
        } // endwhile


  OnCompleteCatalogImport1C // handler triggered after loading all products and information on them  


There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment



Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully


+7(993) 007-18-96



Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number