- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/product/sku.php
- Класс: BitrixCatalogProductSku
- Вызов: Sku::calculateOfferChange
static function calculateOfferChange(int $elementId, int $iblockId): void
{
if (!isset(self::$offers[$elementId]))
return;
$iblockData = CCatalogSku::GetInfoByOfferIBlock($iblockId);
if (!empty($iblockData))
{
$offerDescr = self::$offers[$elementId];
$existCurrentProduct = ($offerDescr['CURRENT_PRODUCT'] > 0);
$existNewProduct = ($offerDescr['NEW_PRODUCT'] > 0);
if ($existCurrentProduct)
{
self::calculateComplete(
$offerDescr['CURRENT_PRODUCT'],
$iblockData['PRODUCT_IBLOCK_ID'],
CatalogProductTable::TYPE_SKU
);
}
if ($existNewProduct)
{
self::calculateComplete(
$offerDescr['NEW_PRODUCT'],
$iblockData['PRODUCT_IBLOCK_ID'],
CatalogProductTable::TYPE_SKU
);
}
if (!$existCurrentProduct || !$existNewProduct)
{
self::disableUpdateAvailable();
$type = (
$existNewProduct
? CatalogProductTable::TYPE_OFFER
: CatalogProductTable::TYPE_FREE_OFFER
);
$result = CatalogModelProduct::update($elementId, array('TYPE' => $type));
unset($result);
self::enableUpdateAvailable();
}
unset($existNewProduct, $existCurrentProduct);
unset($offerDescr);
}
unset(self::$offers[$elementId]);
}