R
R
ragnar_ok2019-10-11 19:51:28
1C-Bitrix
ragnar_ok, 2019-10-11 19:51:28

Bitrix ORM: How to import several thousand elements into an infoblock?

I am implementing the import of several thousand elements into the infoblock.
I'm trying to use Bitrix ORM - the ElementTable::add();output is: To add infoblock elements, use the CIBlockElement::Add() call .
I understand that you can get rid of the method add()that is overridden in ElementTable ( displays an error ) and work with D7 tools with infoblock tables bitrix/modules/iblock/lib/element.php. But for some reason, the developers of Bitrix decided to abandon it? It turns out you need to use the old one CIBlockElement::Add()without options?
How to implement import step by step? Is there any analogue of Batch Processing from Doctrine?
In short, how to optimize this:

foreach ($itemArray as $item) {
  CIBlockElement::Add($item, false, false, false);
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Nikolaev, 2019-10-11
@ragnar_ok

But for some reason, the developers of Bitrix decided to abandon it?

They didn't "decide to refuse", they haven't done it architecturally yet. Infoblock elements are not only an entry in the table, they are also properties that can be stored in two versions, so this is not at all so simple.
If you want atomically and without breaking logic - yes.
In fact, if you have a simple entry, i.e. without properties, you can peep what it does and perform by analogy. It will be generally almost the same for imports.
There are no analogues, but the operation is not so frequent. There is a need for such volumes - usually either these are third-party catalogs (prices, availability, properties, etc.) and here you can’t do without CIblockElement::add, or your own table (and there is already whatever you want, at least sql)

G
Georgy Baruchyan, 2019-10-12
@Snatch87

As a workaround, you can inherit from ElementTable and override the add method in your class, and then implement your own addition

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question