N
N
newked2021-04-16 16:00:46
1C-Bitrix
newked, 2021-04-16 16:00:46

How to send an email notification in Bitrix about adding an element through the website to the infoblock?

Hi all. Guys, I need your help. There was a task to create a form for adding reviews on Bitrix.
I created the "Reviews" infoblock and set it up. Reached the moment of creating a form for adding an element through the site. Everything seems to be clear, but I got into a stupor at a certain moment - it is necessary to send a notification to the corporate mail that a review has been written. I searched in Bitrix in the properties of the infoblock, and did not find anything. Guys, help pliz, tell me where to dig, how to do it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yaroslav Alexandrov, 2021-04-16
@alexyarik

Write your handler in the init.php file, the example below
is https://dev.1c-bitrix.ru/learning/course/index.php...

<?// регистрируем обработчик уведомления
AddEventHandler("iblock", "OnAfterIBlockElementAdd", Array("MessageAdd", "OnAfterIBlockElementAddHandler"));

class MessageAdd
{
    // создаем обработчик события "OnAfterIBlockElementAddHandler"
    function OnAfterIBlockElementAddHandler(&$arFields)
    {
        if($arFields["ID"]>0) 
    {	
           If($arFields['IBLOCK_ID'] == 4) 
       { 

                  $arSend = array(
          'TEXT' => $arFields['NAME'].' - товар '.$preview_picture.''.$detail_picture.''.$section.' , ID товара ='.$arFields["ID"]);
          $arrSite = 's1';
                  CEvent::Send('ART_DTEX_IMPORT',$arrSite,$arSend);
      }
      } 
    }
}

R
Roman Gritsuk, 2021-04-16
@winer

There are no standard email notifications when an IB element is added.
Write an event handler for the OnAfterIBlockElementAdd event . In it, check the IBLOCK_ID for the one you need, and send the mail event via CEvent::Send

N
newked, 2021-04-16
@newked

Roman, do not judge strictly, I'm new in Bitrix. Can you be a little more specific about where to write the handler and how to set up CEvent::Send? The best thing, of course, would be some kind of live example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question