• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/basketitemcollection.php
  • Класс: BitrixSaleBasketItemCollection
  • Вызов: BasketItemCollection::getExistsItems
public function getExistsItems(string $moduleId, int $productId, ?array $properties = [])
{
	$result = [];

	foreach ($this->getBasketItems() as $basketItem)
	{
		if ((int)$basketItem->getField('PRODUCT_ID') === $productId && $basketItem->getField('MODULE') === $moduleId)
		{
			// skip check properties
			if (is_null($properties))
			{
				$result[] = $basketItem;
				continue;
			}

			/** @var BasketPropertiesCollection $basketPropertyCollection */
			$basketPropertyCollection = $basketItem->getPropertyCollection();
			if ($properties)
			{
				if ($basketPropertyCollection->isPropertyAlreadyExists($properties))
				{
					$result[] = $basketItem;
				}
			}
			elseif (count($basketPropertyCollection) === 0)
			{
				$result[] = $basketItem;
			}
		}
	}

	return $result;
}