CCrmProduct::PrepareCatalogProductFields

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmProduct
  4. PrepareCatalogProductFields
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_product.php
  • Класс: \CCrmProduct
  • Вызов: CCrmProduct::PrepareCatalogProductFields
static function PrepareCatalogProductFields(array $arProductID)
{
	if (!Loader::includeModule('catalog'))
	{
		return array();
	}

	if (empty($arProductID) || !is_array($arProductID))
	{
		return array();
	}
	Main\Type\Collection::normalizeArrayValuesByInt($arProductID, true);
	if (empty($arProductID))
	{
		return array();
	}

	$result = array();
	// use for show - direct query without product cache (Catalog\Model\Product)
	$iterator = Catalog\ProductTable::getList(array(
		'select' => array('ID', 'VAT_ID', 'VAT_INCLUDED', 'MEASURE'),
		'filter' => array('@ID' => $arProductID)
	));
	while ($fields = $iterator->fetch())
	{
		$productID = (int)$fields['ID'];
		$result[$productID] = array(
			'PRODUCT_ID' => $productID,
			'TAX_ID' => isset($fields['VAT_ID']) ? (int)$fields['VAT_ID'] : 0,
			'TAX_INCLUDED' => isset($fields['VAT_INCLUDED']) && mb_strtoupper($fields['VAT_INCLUDED']) === 'Y',
			'MEASURE' => isset($fields['MEASURE']) ? (int)$fields['MEASURE'] : 0
		);
	}
	unset($fields, $iterator);

	return $result;
}

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