Add
Description and parameters
bool CCatalog::Add( array arFields );
Method adds a new table entry for binding iblock to the catalog module. Non-static method.
Call parameters
Parameter | Description |
---|---|
arFields | Array with binding parameters containing the following keys:
|
Returned values
Returns true on successfully added record and false otherwise. Error text message can be retrieved using $APPLICATION->GetException().
Before adding an entry/record to the table, checks binding parameters using the method CCatalog::CheckFields (correct parameters are described inside). On successful check, records to database. Attempting to add more than one record with the identical IBLOCK_ID causes database error.
See Also
Examples
Binding iblock to the Catalog module
$arFields = array( 'IBLOCK_ID' => 2, // product iblock code (ID) 'YANDEX_EXPORT' => 'Y', // ); $boolResult = CCatalog::Add($arFields); if ($boolResult == false) { if ($ex = $APPLICATION->GetException()) { $strError = $ex->GetString(); ShowError($strError); } }
Binding iblock to the Catalog module as SKU iblock
$arFields = array( 'IBLOCK_ID' => 2, // SKU iblock code (ID) 'VAT_ID' => 2, // VAT type code (ID) 'PRODUCT_IBLOCK_ID' => 10, // product iblock code (ID) (can be bound or not bound to the Catalog module) 'SKU_PROPERTY_ID' => 14 // binding code (ID) for iblock property with ID=2 to the iblock with ID=10 (property type - SKU) ); $boolResult = CCatalog::Add($arFields); if ($boolResult == false) { if ($ex = $APPLICATION->GetException()) { $strError = $ex->GetString(); ShowError($strError); } }
© «Bitrix24», 2001-2024