• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/product/price.php
  • Класс: BitrixCatalogProductPrice
  • Вызов: Price::handlerAfterUpdateCurrencyBaseRate
static function handlerAfterUpdateCurrencyBaseRate(MainEvent $event)
{
	$params = $event->getParameters();
	if (empty($params))
		return;

	$oldBaseRate = (float)$params['OLD_BASE_RATE'];
	if ($oldBaseRate < 1E-4)
		return;
	$currentBaseRate = (float)$params['CURRENT_BASE_RATE'];
	if (abs($currentBaseRate - $oldBaseRate)/$oldBaseRate < 1E-4)
		return;
	$currency = $params['CURRENCY'];

	$conn = MainApplication::getConnection();
	$helper = $conn->getSqlHelper();

	$query = 'update '.$helper->quote(CatalogPriceTable::getTableName()).
		' set '.$helper->quote('PRICE_SCALE').' = '.$helper->quote('PRICE').' * '.$currentBaseRate.
		' where '.$helper->quote('CURRENCY').' = ''.$helper->forSql($currency).''';
	$conn->queryExecute($query);

	if (defined('BX_COMP_MANAGED_CACHE'))
	{
		$taggedCache = MainApplication::getInstance()->getTaggedCache();
		$taggedCache->clearByTag('currency_id_'.$currency);
	}
}