Documentation

CheckFields

Description and parameters

bool
CCatalog::CheckFields(
 string $ACTION,
 array &$arFields[,
 int $ID = 0]
);

Method checks (and adjusts, if possible) parameters, passed to methods CCatalog::Add and CCatalog::Update. Non-static method.

Call parameters

Parameter Description
ACTION Indicates which method is checked. Possible values:
arFields Associative array with parameters for binding iblock to the Catalog module. Array is passed by link and its values can be updated by the method.
Permissible values:
  • IBLOCK_ID - iblock code (ID);
  • SUBSCRIPTION - flag "Content selling" (Y/N);
  • VAT_ID - VAT type code (ID);
  • PRODUCT_IBLOCK_ID - code (ID) for product iblock (for SKU iblock);
  • SKU_PROPERTY_ID - code (ID) for binding to iblock property (for SKU iblock);
ID Iblock code (ID).

Returned value

In case passed parameters are correct, returns true, otherwise - false. In case, method returned false, via $APPLICATION->GetException() you can get error text.

Required checks

  • for CCatalog::Add
    • key IBLOCK_ID is available and contains code (ID) for existing iblock;
    • if the key SUBSCRIPTION doesn't exist or isn't equal Y, its assigned with the value N;
    • if the key YANDEX_EXPORT doesn't exist or isn't equal Y, its assigned the value N;
    • if the key VAT_ID doesn't exist or less than 0, its assigned the value '0';
    • PRODUCT_IBLOCK_ID and SKU_PROPERTY_ID both are unavailable, both equal null or satisfy the rule:
      • PRODUCT_IBLOCK_ID - code (ID) for existing iblock;
      • SKU_PROPERTY_ID - code (ID) for existing iblock IBLOCK_ID. Property type - "SKU", single property, the field LINK_IBLOCK_ID property = PRODUCT_IBLOCK_ID.

  • for CCatalog::Update
    • iblock with ID shall be a catalog;
    • if the key SUBSCRIPTION exists and isn't equal to Y, its assigned the value N;
    • if the key YANDEX_EXPORT exists and isn't equal to Y, its assigned the value N;
    • if the key VAT_ID exists and less than 0, its assigned the value 0;
    • PRODUCT_IBLOCK_ID and SKU_PROPERTY_ID both are available or both are defined;

See Also

Examples

<?
$arFields = array(
   'IBLOCK_ID' => 2,
   'YANDEX_EXPORT' => 'Y'
);
$boolResult = CCatalog::CheckFields('ADD',$arFields);
if ($boolResult == false)
{
	if ($ex = $APPLICATION->GetException())
	{
		$strError = $ex->GetString();
		ShowError($strError);
	}
}
?>

© «Bitrix24», 2001-2024
Up