当前位置: 首页>>代码示例>>PHP>>正文


PHP LocationTable::resort方法代码示例

本文整理汇总了PHP中Bitrix\Sale\Location\LocationTable::resort方法的典型用法代码示例。如果您正苦于以下问题:PHP LocationTable::resort方法的具体用法?PHP LocationTable::resort怎么用?PHP LocationTable::resort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bitrix\Sale\Location\LocationTable的用法示例。


在下文中一共展示了LocationTable::resort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: importFile

 public static function importFile(&$descriptior)
 {
     $timeLimit = ini_get('max_execution_time');
     if ($timeLimit < $descriptior['TIME_LIMIT']) {
         set_time_limit($descriptior['TIME_LIMIT'] + 5);
     }
     $endTime = time() + $descriptior['TIME_LIMIT'];
     if ($descriptior['STEP'] == 'rebalance') {
         Location\LocationTable::resort();
         Location\LocationTable::resetLegacyPath();
         $descriptior['STEP'] = 'done';
     }
     if ($descriptior['STEP'] == 'import') {
         if (!isset($descriptior['DO_SYNC'])) {
             $res = \Bitrix\Sale\Location\LocationTable::getList(array('select' => array('CNT')))->fetch();
             $descriptior['DO_SYNC'] = intval($res['CNT'] > 0);
         }
         if (!isset($descriptior['TYPES'])) {
             $descriptior['TYPE_MAP'] = static::getTypeMap($descriptior['TYPE_FILE']);
             $descriptior['TYPES'] = static::createTypes($descriptior['TYPE_MAP']);
             $descriptior['SERVICE_MAP'] = static::getServiceMap($descriptior['SERVICE_FILE']);
             $descriptior['SERVICES'] = static::getExistedServices();
         }
         $csvReader = new CSVReader();
         $csvReader->LoadFile($descriptior['FILE']);
         while (time() < $endTime) {
             $block = $csvReader->ReadBlockLowLevel($descriptior['POS'], 100);
             if (!count($block)) {
                 break;
             }
             foreach ($block as $item) {
                 if ($descriptior['DO_SYNC']) {
                     $id = static::checkLocationCodeExists($item['CODE']);
                     if ($id) {
                         $descriptior['CODES'][$item['CODE']] = $id;
                         continue;
                     }
                 }
                 // type
                 $item['TYPE_ID'] = $descriptior['TYPES'][$item['TYPE_CODE']];
                 unset($item['TYPE_CODE']);
                 // parent id
                 if (strlen($item['PARENT_CODE'])) {
                     if (!isset($descriptior['CODES'][$item['PARENT_CODE']])) {
                         $descriptior['CODES'][$item['PARENT_CODE']] = static::checkLocationCodeExists($item['PARENT_CODE']);
                     }
                     $item['PARENT_ID'] = $descriptior['CODES'][$item['PARENT_CODE']];
                 }
                 unset($item['PARENT_CODE']);
                 // ext
                 if (is_array($item['EXT'])) {
                     foreach ($item['EXT'] as $code => $values) {
                         if (is_array($values) && !empty($values)) {
                             if (!isset($descriptior['SERVICES'][$code])) {
                                 $descriptior['SERVICES'][$code] = static::createService(array('CODE' => $code));
                             }
                             foreach ($values as $value) {
                                 if (!strlen($value)) {
                                     continue;
                                 }
                                 $item['EXTERNAL'][] = array('SERVICE_ID' => $descriptior['SERVICES'][$code], 'XML_ID' => $value);
                             }
                         }
                     }
                 }
                 unset($item['EXT']);
                 $res = Location\LocationTable::add($item, array('REBALANCE' => false, 'RESET_LEGACY' => false));
                 if (!$res->isSuccess()) {
                     throw new Main\SystemException('Cannot create location');
                 }
                 $descriptior['CODES'][$item['CODE']] = $res->getId();
             }
         }
         if (!count($block)) {
             unset($descriptior['CODES']);
             $descriptior['STEP'] = 'rebalance';
         }
     }
     return $descriptior['STEP'] == 'done';
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:80,代码来源:importprocess.php


注:本文中的Bitrix\Sale\Location\LocationTable::resort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。