...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_catalog.php
- Класс: \CAllCrmCatalog
- Вызов: CAllCrmCatalog::Add
static function Add($arFields) { if (!Loader::includeModule('catalog')) { return false; } self::$LAST_ERROR = ''; global $DB; $tableName = CCrmCatalog::TABLE_NAME; if (!self::CheckFields('ADD', $arFields, 0)) { return false; } $DB->Add($tableName, $arFields, array(), '', false, 'File: '.__FILE__.'
Line: '.__LINE__); if($DB->db_Error <> '') { self::RegisterError($DB->db_Error); return false; } // -------------- register in catalog module --------------> $catalogId = $arFields['ID']; $arFields = array( 'IBLOCK_ID' => $catalogId ); // get default vat // TODO: replace this code to use preset vat id $defCatVatId = 0; $iterator = \Bitrix\Catalog\VatTable::getList([ 'select' => ['ID', 'SORT'], 'order' => ['SORT' => 'ASC'], 'limit' => 1 ]); $vat = $iterator->fetch(); if (!empty($vat)) { $defCatVatId = (int)$vat['ID']; } unset($vat, $iterator); if ($defCatVatId > 0) { $arFields['VAT_ID'] = $defCatVatId; } unset($defCatVatId); // add crm iblock to catalog $CCatalog = new CCatalog(); $dbRes = $CCatalog->GetList(array(), array('ID' => $catalogId), false, false, array('ID')); if (!$dbRes->Fetch()) // if catalog iblock is not exists { if ($CCatalog->Add($arFields)) { COption::SetOptionString('catalog', 'save_product_without_price', 'Y'); COption::SetOptionString('catalog', 'default_can_buy_zero', 'Y'); } else { self::RegisterError(GetMessage('CRM_ERR_REGISTER_CATALOG')); return false; } } // <------------- register in catalog module -------------- return true; }