当前位置: 首页>>代码示例>>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;未经允许,请勿转载。