• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/basketitem.php
  • Класс: BitrixSaleBasketItem
  • Вызов: BasketItem::getBundleBaseQuantity
public function getBundleBaseQuantity()
{
	if ($this->isBundleParent())
	{
		/** @var BundleCollection $bundleCollection */
		if (!($bundleCollection = $this->getBundleCollection()))
		{
			throw new ObjectNotFoundException('Entity "BasketBundleCollection" not found');
		}

		$bundleChildList = [];
		$result = [];

		$originalQuantity = $this->getQuantity();
		$originalValues = $this->fields->getOriginalValues();
		if (array_key_exists('QUANTITY', $originalValues) && $originalValues['QUANTITY'] !== null)
		{
			$originalQuantity = $originalValues['QUANTITY'];
		}
		/** @var BasketItem $bundleBasketItem */
		foreach ($bundleCollection as $bundleBasketItem)
		{
			$originalBundleQuantity = $bundleBasketItem->getQuantity();
			$originalBundleValues = $bundleBasketItem->getFields()->getOriginalValues();
			if (array_key_exists('QUANTITY', $originalBundleValues)  && $originalBundleValues['QUANTITY'] !== null)
			{
				$originalBundleQuantity = $originalBundleValues['QUANTITY'];
			}

			if ($originalQuantity > 0)
			{
				$bundleQuantity = $originalBundleQuantity / $originalQuantity;
			}
			else
			{
				$bundleQuantity = 0;
			}

			$bundleChildList[]["ITEMS"][] = [
					"PRODUCT_ID" => $bundleBasketItem->getProductId(),
					"QUANTITY" => $bundleQuantity
			];

		}

		if (empty($bundleChildList))
			return false;

		foreach ($bundleChildList as $bundleBasketListDat)
		{
			foreach ($bundleBasketListDat["ITEMS"] as $bundleDat)
			{
				$result[$bundleDat['PRODUCT_ID']] = $bundleDat['QUANTITY'];
			}
		}

		return $result;
	}

	return false;
}