• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/discount/migration/orderdiscountmigrator.php
  • Класс: BitrixSaleDiscountMigrationOrderDiscountMigrator
  • Вызов: OrderDiscountMigrator::createEmptyDiscount
static function createEmptyDiscount(array &$discountData, $accumulate = false)
{
	$accumulate = ($accumulate === true);
	static $emptyFields = null;
	if ($emptyFields === null)
	{
		$emptyFields = array(
			'DISCOUNT_ID' => 0,
			'NAME' => Loc::getMessage('SALE_ORDER_DISCOUNT_MIGRATOR_MESS_CATALOG_DISCOUNT_NAME'),
			'SORT' => 100,
			'PRIORITY' => 1,
			'LAST_DISCOUNT' => 'Y',
			'USE_COUPONS' => 'N'
		);
	}

	static $replaceFields = null;
	static $replaceKeys = null;
	if ($replaceFields === null)
	{
		$replaceFields = array(
			'MODULE_ID' => 'catalog',
			'CONDITIONS' => array(
				'CLASS_ID' => 'CondGroup',
				'DATA' => array('All' => 'AND', 'True' => 'True'),
				'CHILDREN' => array()
			),
			'UNPACK' => '((1 == 1))',
			'ACTIONS' => array(),
			'APPLICATION' => '0'
		);
		$replaceKeys = array(
			'MODULE_ID',
			'CONDITIONS',
			'UNPACK',
			'ACTIONS',
			'APPLICATION'
		);
	}
	static $discountDescr = null;
	if ($discountDescr === null)
	{
		$discountDescr = SaleDiscountFormatter::prepareRow(
			SaleDiscountFormatter::TYPE_SIMPLE,
			Loc::getMessage('SALE_ORDER_DISCOUNT_MIGRATOR_MESS_CATALOG_DISCOUNT_SIMPLE_MESS')
		);
	}
	static $accumulateDescr = null;
	if ($accumulateDescr === null)
	{
		$accumulateDescr = SaleDiscountFormatter::prepareRow(
			SaleDiscountFormatter::TYPE_SIMPLE,
			Loc::getMessage('SALE_ORDER_DISCOUNT_MIGRATOR_MESS_TYPE_ACCUMULATE_EMPTY')
		);
	}
	foreach ($replaceKeys as $key)
	{
		if (array_key_exists($key, $discountData))
			unset($discountData[$key]);
	}
	unset($key);
	$discountData = array_merge($emptyFields, $discountData);
	foreach ($replaceFields as $key => $value)
	{
		$discountData[$key] = $value;
	}
	unset($key, $value);
	if (empty($discountData['ACTIONS_DESCR']))
		$discountData['ACTIONS_DESCR'] = array(
			'BASKET' => array(
				0 => ($accumulate ? $accumulateDescr : $discountDescr)
			)
		);
	if (!$accumulate)
		$discountData['USE_COUPONS'] = ($discountData['COUPON'] != '' ? 'Y' : 'N');
}