- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/model/product.php
- Класс: BitrixCatalogModelProduct
- Вызов: Product::runUpdateExternalActions
static function runUpdateExternalActions($id, array $data): void
{
$product = self::getCacheItem($id);
if (isset($data['actions'][self::ACTION_CHANGE_PARENT_AVAILABLE]))
{
switch ($product['TYPE'])
{
case CatalogProductTable::TYPE_OFFER:
if (isset($data['actions']['SKU_AVAILABLE']))
{
CatalogProductSku::calculateComplete(
$id,
$data['external_fields']['IBLOCK_ID'],
CatalogProductTable::TYPE_OFFER
);
}
self::updateElementModificationTime($id);
break;
case CatalogProductTable::TYPE_SKU:
if (isset($data['actions']['SKU_AVAILABLE']))
{
CatalogProductSku::calculateComplete(
$id,
$data['external_fields']['IBLOCK_ID'],
CatalogProductTable::TYPE_SKU
);
}
break;
case CatalogProductTable::TYPE_PRODUCT:
case CatalogProductTable::TYPE_SET:
self::updateElementModificationTime($id);
break;
}
}
if (isset($data['actions'][self::ACTION_SEND_NOTIFICATIONS]))
{
self::checkSubscription($id, $product);
}
if (isset($data['actions'][self::ACTION_RECALCULATE_SETS]))
{
CCatalogProductSet::recalculateSetsByProduct($id);
}
$changeAvailable = (
isset($product['AVAILABLE'])
&& isset($product[self::PREFIX_OLD.'AVAILABLE'])
&& $product[self::PREFIX_OLD.'AVAILABLE'] != $product['AVAILABLE']
);
if ($changeAvailable)
{
// clear public components cache
CIBlock::clearIblockTagCache($data['external_fields']['IBLOCK_ID']);
// send old event
$eventId = 'OnProductQuantityTrace';
if (
MainConfigOption::get('catalog', 'enable_processing_deprecated_events') === 'Y'
&& Event::existEventHandlersById($eventId)
)
{
$description = [
'ID' => $product['ID'],
'ELEMENT_IBLOCK_ID' => $data['external_fields']['IBLOCK_ID'],
'IBLOCK_ID' => $data['external_fields']['IBLOCK_ID'],
'TYPE' => $product['TYPE'],
'AVAILABLE' => $product['AVAILABLE'],
'CAN_BUY_ZERO' => $product['CAN_BUY_ZERO'],
'NEGATIVE_AMOUNT_TRACE' => $product['CAN_BUY_ZERO'],
'QUANTITY_TRACE' => $product['QUANTITY_TRACE'],
'QUANTITY' => $product['QUANTITY'],
'OLD_QUANTITY' => $product[self::PREFIX_OLD.'QUANTITY'] ?? $product['QUANTITY'],
];
$description['DELTA'] = $description['QUANTITY'] - $description['OLD_QUANTITY'];
$handlerData = [
$product['ID'],
$description,
];
unset($description);
$eventManager = MainEventManager::getInstance();
$handlerList = $eventManager->findEventHandlers('catalog', $eventId);
foreach ($handlerList as $handler)
{
$handler['FROM_MODULE_ID'] = 'catalog';
$handler['MESSAGE_ID'] = $eventId;
ExecuteModuleEventEx($handler, $handlerData);
}
unset($handler, $handlerList);
unset($handlerData);
}
}
unset($product);
}