CCrmProductSection::isIncludesUsedProducts

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmProductSection
  4. isIncludesUsedProducts
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_product_section.php
  • Класс: \CCrmProductSection
  • Вызов: CCrmProductSection::isIncludesUsedProducts
static function isIncludesUsedProducts($iblockId, $sectionId)
{
	$iblockId = intval($iblockId);
	$sectionId = intval($sectionId);
	if ($iblockId <= 0 || $sectionId <= 0)
		return false;

	$result = false;
	$stepSize = 500;

	$element = new CIBlockElement();
	$rs = $element->GetList(
		array('SORT' => 'ASC'),
		array(
			'IBLOCK_ID' => $iblockId,
			'SECTION_ID' => $sectionId,
			'INCLUDE_SUBSECTIONS' => 'Y',
			'CHECK_PERMISSIONS' => 'N'
		),
		false,
		false,
		array('ID')
	);
	if ($rs)
	{
		$i = 0;
		$arProductId = array();
		while ($row = $rs->Fetch())
		{
			$i++;
			$arProductId[] = $row['ID'];
			if ($i === $stepSize)
			{
				$rowsCount = CCrmProductRow::GetList(array(), array('PRODUCT_ID' => $arProductId), array(), false, array());
				if($rowsCount > 0 || CCrmInvoice::HasProductRows($arProductId))
					$result = true;
				$i = 0;
				$arProductId = array();
			}
			if ($result)
				break;
		}
		if (!$result && count($arProductId) > 0)
		{
			$rowsCount = CCrmProductRow::GetList(array(), array('PRODUCT_ID' => $arProductId), array(), false, array());
			if($rowsCount > 0 || CCrmInvoice::HasProductRows($arProductId))
				$result = true;
		}
	}

	return $result;
}

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