本文整理汇总了PHP中Bitrix\Sale\Location\LocationTable::addExtended方法的典型用法代码示例。如果您正苦于以下问题:PHP LocationTable::addExtended方法的具体用法?PHP LocationTable::addExtended怎么用?PHP LocationTable::addExtended使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Sale\Location\LocationTable
的用法示例。
在下文中一共展示了LocationTable::addExtended方法的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'], 10);
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::addExtended($item, array('RESET_LEGACY' => false, 'REBALANCE' => 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';
}