S
S
sagaton2022-04-04 22:17:36
PHP
sagaton, 2022-04-04 22:17:36

How to make a detail type change through a loop?

There is data pulled from the database and saved to a csv file.
When importing a detailed description, no matter how html tried to do it, it was still text.
I found a way that did the transformation of the detailed text, but for me it only works when entering the element and updating it. I have over a hundred. how to make the changes go through the cycle?
here is the code

if ($arResult["DETAIL_TEXT_TYPE"]!=="html") {
    $el = new CIBlockElement;
    $arLoadProductArray = Array(
        "DETAIL_TEXT_TYPE" => "html",
    );
    $res = $el->Update($arResult["ID"], $arLoadProductArray);
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DyoMin, 2022-04-17
@DyoMin

As far as I remember, bitrix does not know how to change/remove infoblock elements with one request.
The option here is to select the required elements via CIBlockElement::GetList(), and then in a loop to perform a change in the type of a detailed description. Yes, this is not optimal, but if this is a one-time processing, then it is quite possible to do it.
The second option is to make a change directly in the database table, without using the infoblock api. In this case, see the structure of the b_iblock_element table. But after this, at least you need to reset the cache. In general, the official documentation does not recommend working directly with the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question