Answer the question
In order to leave comments, you need to log in
How to perform a bulk operation with a database?
You need to write properties for all products based on existing properties.
The problem is that the operation turned out to be voluminous and the server, after 10-15 minutes, returns a 504 error.
There are 20k goods in total, but the situation is worsened by the fact that the properties are multiple, and GetList duplicates the record, which causes the number of iterations to increase tenfold.
How can the problem be solved?
P.S. request code
$vaz2107 = array(
39819, 39820, 39821, 39822, 39823, 39824, 39825,
'ID_GROUP' => 44219
);
$res = CIBlockElement::GetList(
array(),
array(
'IBLOCK_ID' => 42,
'PROPERTY_APPLICABILITY_SECT_VALUE' => $vaz2107,
'ACTIVE' => 'Y',
),
false,
false,
array('ID', 'IBLOCK_ID', 'PROPERTY_APPLICABILITY_SECT', 'PROPERTY_APPLICABILITY_GROUP')
);
while ($data = $res->fetch()) {
$arPropertyGroup[] = $data['PROPERTY_APPLICABILITY_GROUP_VALUE'];
// ID Группы, куда добавляем
array_push($arPropertyGroup, $vaz2107['ID_GROUP']);
$do = CIBlockElement::SetPropertyValuesEx($data['ID'], 42, array(
'APPLICABILITY_GROUP' => $arPropertyGroup
));
}
if ($do == null) {
echo 'ok';
} else {
echo 'no';
}
Answer the question
In order to leave comments, you need to log in
To prevent GetList from duplicating records, you need to change the storage type of infoblock properties to storage in a separate table:
And you also have some strange situation happening here:
$arPropertyGroup[] = $data['PROPERTY_APPLICABILITY_GROUP_VALUE'];
// ID Группы, куда добавляем
array_push($arPropertyGroup, $vaz2107['ID_GROUP']);
$do = CIBlockElement::SetPropertyValuesEx($data['ID'], 42, array(
'APPLICABILITY_GROUP' => $arPropertyGroup
));
Create a console script similar to "crown agents" and run it through the console.
Regarding agents: https://dev.1c-bitrix.ru/learning/course/index.php...
Make an analogue of the file /bitrix/php_interface/cron_events.php
, remove everything related to agents and write your code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question