• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/product/catalogprovider.php
  • Класс: BitrixCatalogProductCatalogProvider
  • Вызов: CatalogProvider::checkProductInStores
private function checkProductInStores($products): SaleResult
	{
		$result = new SaleResult();
		$productStoreDataList = array();
		$canAutoShipList = array();
		$r = $this->canProductListAutoShip($products);
		if ($r->isSuccess())
		{
			$data = $r->getData();
			if (!empty($data['PRODUCT_CAN_AUTOSHIP_LIST']))
			{
				$canAutoShipList = $data['PRODUCT_CAN_AUTOSHIP_LIST'];
			}
		}

		$r = $this->getProductListStores($products);
		if ($r->isSuccess())
		{
			$data = $r->getData();
			if (!empty($data['PRODUCT_STORES_LIST']))
			{
				$productStoreDataList = $data['PRODUCT_STORES_LIST'];
			}
		}

		foreach ($products as $productId => $productData)
		{
			if (!empty($productData['STORE_DATA_LIST']))
			{
				if (!static::isExistsBarcode($productData['STORE_DATA_LIST']))
				{
					$result->addError(
						new SaleResultError(
							MainLocalizationLoc::getMessage(
								"DDCT_DEDUCTION_MULTI_BARCODE_EMPTY", self::getProductCatalogInfo($productId)
							), "DDCT_DEDUCTION_MULTI_BARCODE_EMPTY"
						)
					);
				}
			}
			elseif ($canAutoShipList[$productId] === false)
			{
				if (!isset($productStoreDataList[$productId]))
				{
					$result->addError(
						new SaleResultError(
							MainLocalizationLoc::getMessage(
								"DDCT_DEDUCTION_STORE_EMPTY_ERROR",
								self::getProductCatalogInfo($productId)
							), "DEDUCTION_STORE_ERROR1"
						)
					);
				}
				elseif (count($productStoreDataList[$productId]) > 1)
				{
					$result->addError(
						new SaleResultError(
							MainLocalizationLoc::getMessage(
								"DDCT_DEDUCTION_STORE_ERROR",
								self::getProductCatalogInfo($productId)
							), "DEDUCTION_STORE_ERROR1"
						)
					);
				}
			}
		}

		return $result;

	}