79 foreach ($entities as $entity)
81 $entityId = $entity->getId();
82 if ($entityId !==
null)
84 $res = $this->
updateInternal($entityId, $entity->getChangedFields());
86 if ($res->isSuccess())
88 $savedIds[] = $entityId;
92 $result->addErrors($res->getErrors());
99 if ($res->isSuccess())
101 $id = $res->getData()[
'ID'];
107 $result->addErrors($res->getErrors());
113 if (!empty($savedIds))
121 foreach ($entities as $entity)
123 $entityFields = $fields[$entity->getId()] ??
null;
124 if (!is_array($entityFields))
126 AddMessage2Log(
'Cannot load product ' . $entity->getId(),
'catalog');
129 $entityFields = array_diff_key($entityFields, [
'TYPE' =>
true]);
133 $entity->initFields($entityFields);
227 protected function getList(array $params): array
229 $filter = $params[
'filter'] ?? [];
230 $order = $params[
'order'] ?? [];
231 $nav = $params[
'nav'] ??
false;
233 $iblockElements = [];
236 $iterator = \CIBlockElement::GetList(
250 while ($row = $iterator->fetch())
252 $id = (int)$row[
'ID'];
253 $iblockElements[$id] = $row;
258 if (empty($iblockElements))
266 'QUANTITY_TRACE' =>
'QUANTITY_TRACE_ORIG',
267 'CAN_BUY_ZERO' =>
'CAN_BUY_ZERO_ORIG',
268 'SUBSCRIBE' =>
'SUBSCRIBE_ORIG',
270 $productSelect = array_merge([
'*',
'UF_*'], array_values($specificFields));
272 foreach (array_chunk($listIds, CATALOG_PAGE_SIZE) as $pageIds)
274 $elementsIterator = \CIBlockElement::GetList(
278 'CHECK_PERMISSIONS' =>
'N',
285 if ($detailUrlTemplate)
287 $elementsIterator->SetUrlTemplates($detailUrlTemplate);
289 while ($element = $elementsIterator->getNext())
291 $id = (int)$element[
'ID'];
292 $iblockElements[$id] += $this->replaceRawFromTilda($element);
294 unset($elementsIterator);
297 'select' => $productSelect,
302 while ($product = $productIterator->fetch())
304 $id = (int)$product[
'ID'];
305 unset($product[
'ID']);
306 foreach ($specificFields as $field => $originalField)
308 $product[$field] = $product[$originalField];
309 unset($product[$originalField]);
311 $iblockElements[$id] += $product;
313 unset($productIterator);
316 return $iblockElements;
427 $res = \CIBlockElement::delete($id);
433 if (!$res->isSuccess())
435 $result->addErrors($res->getErrors());
441 $exception = $APPLICATION->GetException();
443 if ($exception && $exception->GetString())
445 $errorMessage = $exception->GetString();
449 $errorMessage =
"Delete operation for entity with id {$id} failed.";
452 $result->addError(
new Error($errorMessage));