CCrmProductRowRestProxy::prepareForSave

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmProductRowRestProxy
  4. prepareForSave
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmProductRowRestProxy
  • Вызов: CCrmProductRowRestProxy::prepareForSave
public function prepareForSave(&$fields)
{
	$fieldsInfo = $this->getFieldsInfo();
	$this->internalizeFields($fields, $fieldsInfo);

	$productId = (int)($fields['PRODUCT_ID'] ?? null);
	if ($productId && Loader::includeModule('catalog'))
	{
		$productRow = Catalog\ProductTable::getRow([
			'select' => [
				'PRODUCT_NAME' => 'IBLOCK_ELEMENT.NAME',
				'TYPE',
			],
			'filter' => [
				'=ID' => $productId,
			],
		]);
		if ($productRow)
		{
			$fields['TYPE'] = (int)$productRow['TYPE'];
			$fields['PRODUCT_NAME'] ??= $productRow['PRODUCT_NAME'];
		}
	}

	if (isset($fields['TAX_RATE']))
	{
		if (
			(float)$fields['TAX_RATE'] > 0
			|| $fields['TAX_RATE'] === 0
			|| (
				is_string($fields['TAX_RATE'])
				&& isset($fields['TAX_RATE'][0])
				&& $fields['TAX_RATE'][0] === '0'
			)
		)
		{
			$fields['TAX_RATE'] = (float)$fields['TAX_RATE'];
		}
		else
		{
			$fields['TAX_RATE'] = null;
		}
	}
}

Добавить комментарий