• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/grid/productaction.php
  • Класс: BitrixCatalogGridProductAction
  • Вызов: ProductAction::convertSaleProducts
static function convertSaleProducts(array $productIdList, int $type): MainResult
{
	$saleType = SaleInternalsCatalogProductTypeMapper::getType($type);

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

	$productIdSql = $helper->forSql(implode(',', $productIdList));
	$sql = sprintf(
		'UPDATE %s SET TYPE = %s WHERE PRODUCT_ID IN (%s)',
		$helper->quote(SaleInternalsBasketTable::getTableName()),
		$saleType ?: $helper->convertToDb($saleType),
		$productIdSql
	);

	try
	{
		$connection->query($sql);
	}
	catch (MainDBSqlQueryException $exception)
	{
		return (new MainResult())->addError(new MainError($exception->getMessage()));
	}

	return new MainResult();
}