N
N
nikegk2017-02-16 20:47:00
1C-Bitrix
nikegk, 2017-02-16 20:47:00

How to copy the contents of an infoblock to another by event?

Good evening.
Can you please tell me if it is possible to somehow copy the contents of an infoblock (with all categories and properties) to another by event?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Gritsuk, 2017-02-17
@nikegk

Do you have a question "how to copy an infoblock?" or "how to hang it on an event?":
If you need to hang it on an event, then it's done like this:
code in init.php

$eventManager = \Bitrix\Main\EventManager::getInstance();

$eventManager->addEventHandler(
    "main",//код модуля из которого это событие
    "EventName",//Нужное Вам событие
    array('Vendor\Iblock\Copy', "copyIblock")//Класс и имя функции копирования
);

If you still need to write a copy, then it is worth considering that before copying the element, you need to copy it to a new infoblock:
If this is a catalog, then also information from the catalog module:
If this is a catalog with trade offers, then, respectively, all of the above for trade offers.
You can see how part of what is written above is executed in the module from the marketplace - asd.iblock.
As a result, the main problem is just copying the infoblock, and attaching a function to an event is a matter of minutes.

S
Sergey, 2017-02-17
@gangstarcj

You can) And how to do this there are several options. You can just make a getlist, collect an array, and then add

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question