• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/product/catalogprovider.php
  • Класс: BitrixCatalogProductCatalogProvider
  • Вызов: CatalogProvider::checkProductBarcodes
static function checkProductBarcodes(array $productData, array $productStoreData, array $storeData = array())
	{
		$result = new SaleResult();

		$productId = $productData['PRODUCT_ID'];
		$storeId = $productStoreData['STORE_ID'];

		if (isset($storeData['BARCODE']) && count($storeData['BARCODE']) > 0)
		{
			foreach ($storeData['BARCODE'] as $barcodeValue)
			{
				if (trim($barcodeValue) == "" && $storeData['IS_BARCODE_MULTI'] === true)
				{
					$result->addError(
						new SaleResultError(
							MainLocalizationLoc::getMessage(
								"DDCT_DEDUCTION_MULTI_BARCODE_EMPTY",
								array_merge(
									self::getProductCatalogInfo($productId),
									array("#STORE_ID#" => $storeId)
								)
							), "DDCT_DEDUCTION_MULTI_BARCODE_EMPTY"
						)
					);
					continue;
				}
				if (!empty($barcodeValue))
				{
					$fields = [
						'=STORE_ID' => static::CATALOG_PROVIDER_EMPTY_STORE_ID,
						'=BARCODE' => $barcodeValue,
						'=PRODUCT_ID' => $productId
					];

					if ($storeData['IS_BARCODE_MULTI'] === true)
					{
						$fields['=STORE_ID'] = $storeId;
					}
					$iterator = CatalogStoreBarcodeTable::getList([
						'select' => ['ID'],
						'filter' => $fields,
						'limit' => 1,
					]);
					$row = $iterator->fetch();
					unset($iterator);

					if (empty($row))
					{
						$result->addError( new SaleResultError(
							MainLocalizationLoc::getMessage(
								"DDCT_DEDUCTION_BARCODE_ERROR",
								array_merge(self::getProductCatalogInfo($productId), array("#BARCODE#" => $barcodeValue))
							),
							"DDCT_DEDUCTION_BARCODE_ERROR"
						));
					}
				}
			}
		}
		else
		{
			$result->addError( new SaleResultError(
				MainLocalizationLoc::getMessage(
					"DDCT_DEDUCTION_MULTI_BARCODE_EMPTY",
					array_merge(self::getProductCatalogInfo($productId), array("#STORE_ID#" => $storeId))
				),
				"DDCT_DEDUCTION_MULTI_BARCODE_EMPTY"
			));
		}
		return $result;
	}