S
S
Shenku2021-11-24 14:41:46
1C-Bitrix
Shenku, 2021-11-24 14:41:46

How to use Iblock inside your class?

I needed to create my own class, I created it and connected it, I need to add an element through the method, I try to connect iblock and tried it through use and . How do I create an instance of . Gives an error. \Bitrix\Main\Loader::includeModule( 'iblock' );

$el = new CIBlockElement();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2021-11-24
@Sh3nku

use Bitrix\Iblock is not necessary and will not help, it is a namespace.
You also need to load the Iblock module, since the class you need in it, when the module is loaded, the autoloader of its classes is initialized.

use Bitrix\Main\Loader;
Loader::includeModule("iblock");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question