當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CIBlockElement::CheckFields方法代碼示例

本文整理匯總了PHP中CIBlockElement::CheckFields方法的典型用法代碼示例。如果您正苦於以下問題:PHP CIBlockElement::CheckFields方法的具體用法?PHP CIBlockElement::CheckFields怎麽用?PHP CIBlockElement::CheckFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CIBlockElement的用法示例。


在下文中一共展示了CIBlockElement::CheckFields方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Add

 public static function Add($arFields)
 {
     if (!CModule::IncludeModule('catalog')) {
         return false;
     }
     global $DB;
     $element = new CIBlockElement();
     $ID = isset($arFields['ID']) ? $arFields['ID'] : null;
     if ($ID === null) {
         //Try to create a CIBlockElement
         $arElement = array();
         if (isset($arFields['NAME'])) {
             $arElement['NAME'] = $arFields['NAME'];
         }
         if (isset($arFields['SORT'])) {
             $arElement['SORT'] = $arFields['SORT'];
         }
         if (isset($arFields['ACTIVE'])) {
             $arElement['ACTIVE'] = $arFields['ACTIVE'];
         }
         if (isset($arFields['DETAIL_PICTURE'])) {
             $arElement['DETAIL_PICTURE'] = $arFields['DETAIL_PICTURE'];
         }
         if (isset($arFields['DESCRIPTION'])) {
             $arElement['DETAIL_TEXT'] = $arFields['DESCRIPTION'];
             $arElement['DETAIL_TEXT_TYPE'] = 'text';
         }
         if (isset($arFields['DESCRIPTION_TYPE'])) {
             $arElement['DETAIL_TEXT_TYPE'] = $arFields['DESCRIPTION_TYPE'];
         }
         if (isset($arFields['PREVIEW_PICTURE'])) {
             $arElement['PREVIEW_PICTURE'] = $arFields['PREVIEW_PICTURE'];
         }
         if (isset($arFields['PREVIEW_TEXT'])) {
             $arElement['PREVIEW_TEXT'] = $arFields['PREVIEW_TEXT'];
             $arElement['PREVIEW_TEXT_TYPE'] = 'text';
         }
         if (isset($arFields['PREVIEW_TEXT_TYPE'])) {
             $arElement['PREVIEW_TEXT_TYPE'] = $arFields['PREVIEW_TEXT_TYPE'];
         }
         if (isset($arFields['CATALOG_ID'])) {
             $arElement['IBLOCK_ID'] = intval($arFields['CATALOG_ID']);
         } else {
             $arElement['IBLOCK_ID'] = $arFields['CATALOG_ID'] = CCrmCatalog::EnsureDefaultExists();
         }
         if (isset($arFields['SECTION_ID'])) {
             $arElement['IBLOCK_SECTION_ID'] = $arFields['SECTION_ID'];
             $arElement['IBLOCK_SECTION'] = array($arElement['IBLOCK_SECTION_ID']);
         }
         if (isset($arFields['XML_ID'])) {
             $arElement['XML_ID'] = $arFields['XML_ID'];
         } else {
             if (isset($arFields['ORIGINATOR_ID']) || isset($arFields['ORIGIN_ID'])) {
                 if (isset($arFields['ORIGINATOR_ID']) && isset($arFields['ORIGIN_ID'])) {
                     $arElement['XML_ID'] = $arFields['ORIGINATOR_ID'] . '#' . $arFields['ORIGIN_ID'];
                 } else {
                     if (isset($arFields['ORIGINATOR_ID'])) {
                         $arElement['XML_ID'] = $arFields['ORIGINATOR_ID'] . '#';
                     } else {
                         $arElement['XML_ID'] = '#' . $arFields['ORIGIN_ID'];
                     }
                 }
             } else {
                 if ($arElement['IBLOCK_ID'] != self::getDefaultCatalogId()) {
                     $arElement['XML_ID'] = '#';
                 }
             }
         }
         if (!$element->CheckFields($arElement)) {
             self::RegisterError($element->LAST_ERROR);
             return false;
         }
         if (isset($arFields['PROPERTY_VALUES'])) {
             $arElement['PROPERTY_VALUES'] = $arFields['PROPERTY_VALUES'];
         }
         $ID = intval($element->Add($arElement));
         if ($ID <= 0) {
             self::$LAST_ERROR = $element->LAST_ERROR;
             return false;
         }
         $arFields['ID'] = $ID;
     }
     if (!self::CheckFields('ADD', $arFields, 0)) {
         $element->Delete($ID);
         return false;
     }
     $CCatalogProduct = new CCatalogProduct();
     $arCatalogProductFields = array('ID' => $ID, 'QUANTITY' => 0);
     if (isset($arFields['VAT_INCLUDED'])) {
         $arCatalogProductFields['VAT_INCLUDED'] = $arFields['VAT_INCLUDED'];
     }
     if (isset($arFields['VAT_ID']) && !empty($arFields['VAT_ID'])) {
         $arCatalogProductFields['VAT_ID'] = $arFields['VAT_ID'];
     }
     if (isset($arFields['MEASURE']) && !empty($arFields['MEASURE'])) {
         $arCatalogProductFields['MEASURE'] = $arFields['MEASURE'];
     }
     if ($CCatalogProduct->Add($arCatalogProductFields)) {
         if (isset($arFields['PRICE']) && isset($arFields['CURRENCY_ID'])) {
             self::setPrice($ID, $arFields['PRICE'], $arFields['CURRENCY_ID']);
//.........這裏部分代碼省略.........
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:101,代碼來源:crm_product.php


注:本文中的CIBlockElement::CheckFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。