1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
iblockxmlimport.php
См. документацию.
1<?php
3
4Loc::loadMessages(__FILE__);
5
6final class CIBlockXmlImport
7{
8 const ACTION_NOTHING = 'N';
9 const ACTION_DEACTIVATE = 'A';
10 const ACTION_REMOVE = 'D';
11
12 const STEP_INIT_IMPORT_TABLES = 'INIT_IMPORT_TABLES';
13 const STEP_READ_XML = 'READ_XML';
14 const STEP_INDEX_IMPORT_TABLES = 'INDEX_IMPORT_TABLES';
15 const STEP_IMPORT_METADATA = 'IMPORT_METADATA';
16 const STEP_IMPORT_SECTIONS = 'IMPORT_SECTIONS';
17 const STEP_MISSING_SECTIONS = 'MISSING_SECTIONS';
18 const STEP_RESORT_SECTIONS = 'RESORT_SECTIONS';
19 const STEP_IMPORT_ELEMENTS = 'IMPORT_ELEMENTS';
20 const STEP_MISSING_ELEMENTS = 'MISSING_ELEMENTS';
21 const STEP_IMPORT_PRODUCT_BUNDLES = 'IMPORT_PRODUCT_BUNDLES';
22 const STEP_FINAL = 'FINAL';
23
26
27 const TRANSLITERATION_ON_ADD = 0x0001;
29
30 const SESSION_STORAGE_ID = 'BX_CML2_IMPORT';
31
33 private $xmlImport = null;
34
35 private $fileHandler = null;
36 private $fileParameters = [
37 'PATH' => '',
38 'ABSOLUTE_PATH' => '',
39 'FILES_DIRECTORY' => '',
40 'SIZE' => 0
41 ];
42
43 private $parameters = [];
44
45 private $config = [];
46
47 private $stepList = [
48 self::STEP_INIT_IMPORT_TABLES,
49 self::STEP_READ_XML,
50 self::STEP_INDEX_IMPORT_TABLES,
51 self::STEP_IMPORT_METADATA,
52 self::STEP_IMPORT_SECTIONS,
53 self::STEP_MISSING_SECTIONS,
54 self::STEP_RESORT_SECTIONS,
55 self::STEP_IMPORT_ELEMENTS,
56 self::STEP_IMPORT_PRODUCT_BUNDLES,
57 self::STEP_MISSING_ELEMENTS,
58 self::STEP_FINAL
59 ];
60
61 private $stepId = null;
62 private $stepParameters = null;
63 private $final = false;
64 private $iblockId = null;
65
66 private $message = '';
67
68 private $progressCounter = [];
69
70 private $errors = [];
71
72 private $startTime = null;
73
74 public function __construct()
75 {
76
77 }
78
79 public function __destruct()
80 {
81 $this->closeXmlFile();
82 $this->destroyXmlImporter();
83 }
84
85 public function init(array $parameters, array $config = [])
86 {
87 $this->startTime = time();
88 $this->final = false;
89 $this->clearErrors();
90 $this->setParameters($parameters);
91 if (!$this->isSuccess())
92 return;
93 $this->setConfig($config);
94 if (!$this->isSuccess())
95 return;
96 $this->initSessionStorage();
97 if (!$this->isSuccess())
98 return;
99 $this->internalInit();
100 }
101
102 private function initSessionStorage()
103 {
104 if (!isset($_SESSION[self::SESSION_STORAGE_ID]) || !is_array($_SESSION[self::SESSION_STORAGE_ID]))
105 $_SESSION[self::SESSION_STORAGE_ID] = [];
106 if (!isset($_SESSION[self::SESSION_STORAGE_ID]['SECTIONS_MAP']))
107 $_SESSION[self::SESSION_STORAGE_ID]['SECTIONS_MAP'] = null;
108 if (!isset($_SESSION[self::SESSION_STORAGE_ID]['PRICES_MAP']))
109 $_SESSION[self::SESSION_STORAGE_ID]['PRICES_MAP'] = null;
110 $this->initStepParameters();
111 }
112
113 private function initStepParameters()
114 {
115 if (
116 !isset($_SESSION[self::SESSION_STORAGE_ID]['STEP_ID'])
117 || (
118 !isset($_SESSION[self::SESSION_STORAGE_ID]['STEP_PARAMETERS'])
119 || !is_array($_SESSION[self::SESSION_STORAGE_ID]['STEP_PARAMETERS'])
120 )
121 )
122 {
123 $_SESSION[self::SESSION_STORAGE_ID]['STEP_ID'] = reset($this->stepList);
124 $_SESSION[self::SESSION_STORAGE_ID]['STEP_PARAMETERS'] = [];
125 }
126 if (!in_array(
127 $_SESSION[self::SESSION_STORAGE_ID]['STEP_ID'],
128 $this->stepList
129 ))
130 {
131 $this->addError(Loc::getMessage('IBLOCK_XML_IMPORT_ERR_BAD_STEP_ID'));
132 return;
133 }
134 $this->stepId = &$_SESSION[self::SESSION_STORAGE_ID]['STEP_ID'];
135 $this->stepParameters = &$_SESSION[self::SESSION_STORAGE_ID]['STEP_PARAMETERS'];
136 }
137
141 private function internalInit(): void
142 {
143 $this->closeXmlFile();
144 $this->destroyXmlImporter();
145 $this->createXmlImporter();
146 }
147
151 public function isFinal(): bool
152 {
153 return $this->final;
154 }
155
159 public function run(): void
160 {
161 $this->setXmlImporterParameters();
162 $this->setMessage('');
163 $this->clearProgressCounter();
164 switch ($this->getCurrentStep())
165 {
166 case self::STEP_INIT_IMPORT_TABLES:
167 $this->initTemporaryTablesAction();
168 break;
169 case self::STEP_READ_XML:
170 $this->readXmlAction();
171 break;
172 case self::STEP_INDEX_IMPORT_TABLES:
173 $this->indexTemporaryTablesAction();
174 break;
175 case self::STEP_IMPORT_METADATA:
176 $this->importMetadataAction();
177 break;
178 case self::STEP_IMPORT_SECTIONS:
179 $this->importSectionsAction();
180 break;
181 case self::STEP_MISSING_SECTIONS:
182 $this->processMissingSectionsAction();
183 break;
184 case self::STEP_RESORT_SECTIONS:
185 $this->resortSectionsAction();
186 break;
187 case self::STEP_IMPORT_ELEMENTS:
188 $this->importElementsAction();
189 break;
190 case self::STEP_MISSING_ELEMENTS:
191 $this->processMissingElementsAction();
192 break;
193 case self::STEP_IMPORT_PRODUCT_BUNDLES:
194 $this->importProductBundlesAction();
195 break;
196 case self::STEP_FINAL:
197 $this->finalAction();
198 break;
199 }
200 }
201
205 public function getStepResult(): array
206 {
207 $result = [];
208 if ($this->isSuccess())
209 {
210 $result['TYPE'] = self::RESULT_TYPE_SUCCESS;
211 $result['MESSAGE'] = $this->getMessage();
212 $result['IS_FINAL'] = 'Y';
213 if (!$this->isFinal())
214 {
215 $result['IS_FINAL'] = 'N';
216 $progress = $this->getProgressCounter();
217 if (!empty($progress))
218 $result['PROGRESS'] = $progress;
219 unset($progress);
220 }
221 }
222 else
223 {
224 $result['TYPE'] = self::RESULT_TYPE_ERROR;
225 $result['ERROR'] = implode("\n", $this->getErrors());
226 $result['IS_FINAL'] = 'Y';
227 }
228
229 return $result;
230 }
231
235 public function getIblockId(): ?int
236 {
237 return $this->iblockId;
238 }
239
243 public function isSuccess(): bool
244 {
245 return empty($this->errors);
246 }
247
251 public function getErrors(): array
252 {
253 return $this->errors;
254 }
255
259 public function clearErrors(): void
260 {
261 $this->errors = [];
262 }
263
268 private function addError(string $error): void
269 {
270 $error = trim($error);
271 if ($error === '')
272 {
273 return;
274 }
275 $this->errors[] = $error;
276 }
277
282 private function setParameters(array $parameters): void
283 {
284 $this->prepareParameters($parameters);
285 if (!$this->isSuccess())
286 return;
287 $this->parameters = $parameters;
288 }
289
294 private function prepareParameters(array &$parameters): void
295 {
296 $parameters = array_filter($parameters, [__CLASS__, 'clearNull']);
297 $parameters = array_merge($this->getDefaultParameters(), $parameters);
298
299 $parameters['FILE'] = trim($parameters['FILE']);
300 if ($parameters['FILE'] === '')
301 {
302 $this->addError(Loc::getMessage('IBLOCK_XML_IMPORT_ERR_PARAMETER_FILE_IS_EMPTY'));
303 }
304 else
305 {
306 $rawFilename = $parameters['FILE'];
307 if(
308 file_exists($rawFilename)
309 && is_file($rawFilename)
310 && (
311 mb_substr($rawFilename, -4) === ".xml"
312 )
313 )
314 {
315 $this->fileParameters['PATH'] = mb_substr($rawFilename, mb_strlen($_SERVER['DOCUMENT_ROOT']));
316 $this->fileParameters['ABSOLUTE_PATH'] = $rawFilename;
317 }
318 else
319 {
320 $rawFilename = trim(str_replace("\\", '/', $rawFilename), '/');
321 $filename = rel2abs($_SERVER['DOCUMENT_ROOT'], '/'.$rawFilename);
322 if (mb_strlen($filename) > 1 && $filename === '/'.$rawFilename)
323 {
324 $this->fileParameters['PATH'] = $filename;
325 $this->fileParameters['ABSOLUTE_PATH'] = $_SERVER['DOCUMENT_ROOT'].$filename;
326 }
327 unset($filename, $rawFilename);
328 }
329 $this->fileParameters['FILES_DIRECTORY'] = mb_substr(
330 $this->fileParameters['ABSOLUTE_PATH'],
331 0,
332 mb_strrpos($this->fileParameters['ABSOLUTE_PATH'], '/') + 1
333 );
334 }
335
336 $parameters['IBLOCK_TYPE'] = trim($parameters['IBLOCK_TYPE']);
337
338 if (!is_array($parameters['SITE_LIST']))
339 $parameters['SITE_LIST'] = [$parameters['SITE_LIST']];
340
341 }
342
347 private function getParameter(string $name)
348 {
349 if ($name === '')
350 {
351 return null;
352 }
353
354 return ($this->parameters[$name] ?? null);
355 }
356
360 private function getDefaultParameters(): array
361 {
362 return [
363 'FILE' => '',
364 'IBLOCK_TYPE' => '',
365 'SITE_LIST' => [],
366 'MISSING_SECTION_ACTION' => self::ACTION_NOTHING,
367 'MISSING_ELEMENT_ACTION' => self::ACTION_NOTHING,
368 'INTERVAL' => 30,
369 ];
370 }
371
376 private function setConfig(array $config): void
377 {
378 $this->prepareConfig($config);
379 if (!$this->isSuccess())
380 {
381 return;
382 }
383 $this->config = $config;
384 }
385
390 private function prepareConfig(array &$config): void
391 {
392 $config = array_filter($config, [__CLASS__, 'clearNull']);
393 $config = array_merge($this->getDefaultConfig(), $config);
394 }
395
399 private function getConfig(): array
400 {
401 return $this->config;
402 }
403
408 private function getConfigFieldValue(string $field)
409 {
410 if ($field === '')
411 {
412 return null;
413 }
414
415 return ($this->config[$field] ?? null);
416 }
417
421 private function getDefaultConfig(): array
422 {
423 return [
424 'USE_CRC' => true,
425 'PREVIEW_PICTURE_SETTINGS' => false,
426 'DETAIL_PICTURE_SETTINGS' => false,
427 'USE_OFFERS' => false, // ?
428 'FORCE_OFFERS' => false, // ?
429 'USE_IBLOCK_TYPE_ID' => false, // ?
430 'TRANSLITERATION' => [
431 'MODE' => 0,
432 'SETTINGS' => [
433 'TRANS_LEN' => 255,
434 'TRANS_CASE' => 'L',
435 'TRANS_SPACE' => '-',
436 'TRANS_OTHER' => '-',
437 'TRANS_EAT' => 'Y',
438 ],
439 ],
440 'SKIP_ROOT_SECTION' => false, // ?
441 'DISABLE_CHANGE_PRICE_NAME' => false,
442 'TABLE_NAME' => 'b_xml_tree',
443 'READ_BLOCKSIZE' => 1024,
444 'IBLOCK_CACHE_MODE' => \CIBlockCMLImport::IBLOCK_CACHE_FINAL,
445 ];
446 }
447
451 private function getCurrentStep()
452 {
453 return $this->stepId;
454 }
455
460 private function setCurrentStep($step): void
461 {
462 $this->stepId = $step;
463 }
464
468 private function nextStep(): void
469 {
470 $index = array_search($this->getCurrentStep(), $this->stepList);
471 if (isset($this->stepList[$index+1]))
472 {
473 $this->setCurrentStep($this->stepList[$index + 1]);
474 }
475 else
476 {
477 $this->final = true;
478 }
479 }
480
485 private function setMessage(string $message): void
486 {
487 $this->message = $message;
488 }
489
493 private function getMessage(): string
494 {
495 return $this->message;
496 }
497
501 private function clearProgressCounter(): void
502 {
503 $this->progressCounter = [];
504 }
505
511 private function setProgressCounter(int $total, int $current): void
512 {
513 $this->progressCounter = [
514 'TOTAL' => $total,
515 'CURRENT' => $current
516 ];
517 }
518
522 private function getProgressCounter(): ?array
523 {
524 return (!empty($this->progressCounter) ? $this->progressCounter : null);
525 }
526
530 private function setXmlImporterParameters(): void
531 {
532 $this->xmlImport->InitEx($this->stepParameters, $this->getXmlImporterConfig());
533 }
534
538 private function getXmlImporterConfig(): array
539 {
540 $config = $this->getConfig();
541 $result =
542 [
543 'files_dir' => $this->fileParameters['FILES_DIRECTORY'],
544 'use_crc' => $config['USE_CRC'],
545 'preview' => $config['PREVIEW_PICTURE_SETTINGS'],
546 'detail' => $config['DETAIL_PICTURE_SETTINGS'],
547 'use_offers' => $config['USE_OFFERS'],
548 'force_offers' => $config['FORCE_OFFERS'],
549 'use_iblock_type_id' => $config['USE_IBLOCK_TYPE_ID'],
550 'skip_root_section' => $config['SKIP_ROOT_SECTION'],
551 'disable_change_price_name' => $config['DISABLE_CHANGE_PRICE_NAME'],
552 'table_name' => $config['TABLE_NAME'],
553 'iblock_cache_mode' => $config['IBLOCK_CACHE_MODE'],
554 ]
555 + $this->getXmlImporterTransliterationSettings()
556 ;
557 unset($config);
558
559 return $result;
560 }
561
565 private function initTemporaryTablesAction(): void
566 {
567 $result = $this->xmlImport->initializeTemporaryTables();
568
569 if (!$result)
570 {
571 $this->addError(Loc::getMessage('IBLOCK_XML_IMPORT_ERR_CANNOT_PREPARE_TEMPORARY_TABLES'));
572 }
573 $this->nextStep();
574 }
575
579 private function readXmlAction(): void
580 {
581 $this->openXmlFile();
582 if (!$this->isSuccess())
583 {
584 return;
585 }
586 if ($this->xmlImport->ReadXMLToDatabase(
587 $this->fileHandler,
588 $this->stepParameters,
589 $this->getParameter('INTERVAL'),
590 $this->getConfigFieldValue('READ_BLOCKSIZE')
591 ))
592 {
593 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_XML_FILE_READ_COMPLETE'));
594 $this->nextStep();
595 }
596 else
597 {
598 $this->setMessage(Loc::getMessage(
599 'IBLOCK_XML_IMPORT_MESS_XML_FILE_READ_PROGRESS',
600 ['#PERCENT#' => $this->getXmlFileProgressPercent()]
601 ));
602 }
603 $this->closeXmlFile();
604 }
605
609 private function indexTemporaryTablesAction(): void
610 {
611 if (!$this->xmlImport->IndexTemporaryTables())
612 {
613 $this->addError(Loc::getMessage('IBLOCK_XML_IMPORT_ERR_CANNOT_CREATE_TEMPORARY_TABLES_INDEX'));
614 return;
615 }
616 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_CREATE_TEMPORARY_TABLES_INDEX_COMPLETE'));
617 $this->nextStep();
618 }
619
623 private function importMetadataAction(): void
624 {
625 $result = $this->xmlImport->ImportMetaData(
626 $this->xmlImport->GetRoot(),
627 $this->getParameter('IBLOCK_TYPE'),
628 $this->getParameter('SITE_LIST')
629 );
630 if ($result === true)
631 {
632 $this->nextStep();
633 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_METADATA_IMPORT_COMPLETE'));
634 }
635 else
636 {
637 if (is_array($result))
638 {
639 $result = "\n" . implode("\n", $result);
640 }
641 $this->addError(Loc::getMessage(
642 'IBLOCK_XML_IMPORT_ERR_METADATA_IMPORT_FAILURE',
643 ['#ERROR#' => $result]
644 ));
645 }
646 unset($result);
647 }
648
652 private function importSectionsAction(): void
653 {
654 $this->xmlImport->freezeIblockCache();
655 $result = $this->xmlImport->ImportSections();
656 $this->xmlImport->unFreezeIblockCache();
657 $this->xmlImport->clearIblockCacheOnHit();
658 if ($result === true)
659 {
660 $this->nextStep();
661 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_IBLOCK_SECTIONS_IMPORT_COMPLETE'));
662 }
663 else
664 {
665 $this->addError(Loc::getMessage(
666 'IBLOCK_XML_IMPORT_ERR_IBLOCK_SECTIONS_IMPORT_FAILURE',
667 ['#ERROR#' => $result]
668 ));
669 }
670 }
671
675 private function processMissingSectionsAction(): void
676 {
677 $this->xmlImport->freezeIblockCache();
678 $this->xmlImport->DeactivateSections($this->getParameter('MISSING_SECTION_ACTION'));
679 $this->xmlImport->SectionsResort();
680 $this->xmlImport->unFreezeIblockCache();
681 $this->xmlImport->clearIblockCacheOnHit();
682 $this->nextStep();
683 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_PROCESS_MISSING_IBLOCK_SECTIONS_COMPLETE'));
684 }
685
689 private function resortSectionsAction(): void
690 {
691 $this->xmlImport->freezeIblockCache();
692 $this->xmlImport->SectionsResort();
693 $this->xmlImport->unFreezeIblockCache();
694 $this->xmlImport->clearIblockCacheOnHit();
695 $this->nextStep();
696 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_IBLOCK_SECTIONS_RESORT_COMPLETE'));
697 }
698
702 private function importElementsAction(): void
703 {
704 $this->xmlImport->freezeIblockCache();
705 $result = $this->xmlImport->GetTotalCountElementsForImport();
706 if (!$result)
707 {
708 $this->addError(Loc::getMessage(
709 'IBLOCK_XML_IMPORT_ERR_ELEMENTS_IMPORT_FAILURE',
710 ['#ERROR#' => $this->xmlImport->LAST_ERROR]
711 ));
712
713 return;
714 }
715 $this->xmlImport->ReadCatalogData(
716 $_SESSION[self::SESSION_STORAGE_ID]['SECTIONS_MAP'],
717 $_SESSION[self::SESSION_STORAGE_ID]['PRICES_MAP']
718 );
719 $result = $this->xmlImport->ImportElements(
720 $this->startTime,
721 $this->getParameter('INTERVAL')
722 );
723 $result = $this->xmlImport->updateCounters($result);
724 $this->xmlImport->unFreezeIblockCache();
725 $this->xmlImport->clearIblockCacheOnHit();
726 if ($result == 0)
727 {
728 $this->nextStep();
729 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_IBLOCK_ELEMENTS_IMPORT_COMPLETE'));
730 }
731 else
732 {
733 $this->setMessage(Loc::getMessage(
734 'IBLOCK_XML_IMPORT_MESS_IBLOCK_ELEMENTS_IMPORT_PROGRESS',
735 [
736 '#TOTAL#' => $this->stepParameters['DONE']['ALL'],
737 '#DONE#' => $this->stepParameters['DONE']['CRC']
738 ]
739 ));
740 $this->setProgressCounter(
741 $this->stepParameters['DONE']['ALL'],
742 $this->stepParameters['DONE']['CRC']
743 );
744 }
745 }
746
750 private function processMissingElementsAction(): void
751 {
752 $this->xmlImport->freezeIblockCache();
753 $result = $this->xmlImport->DeactivateElement(
754 $this->getParameter('MISSING_ELEMENT_ACTION'),
755 $this->startTime,
756 $this->getParameter('INTERVAL')
757 );
758 $result = $this->xmlImport->updateCounters($result);
759 $this->xmlImport->unFreezeIblockCache();
760 $this->xmlImport->clearIblockCacheOnHit();
761 if ($result == 0)
762 {
763 $this->nextStep();
764 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_PROCESS_MISSING_IBLOCK_ELEMENTS_COMPLETE'));
765 }
766 else
767 {
768 $this->setMessage(Loc::getMessage(
769 'IBLOCK_XML_IMPORT_MESS_IBLOCK_ELEMENTS_IMPORT_PROGRESS',
770 [
771 '#TOTAL#' => $this->stepParameters['DONE']['ALL'],
772 '#DONE#' => $this->stepParameters['DONE']['NON']
773 ]
774 ));
775 $this->setProgressCounter(
776 $this->stepParameters['DONE']['ALL'],
777 $this->stepParameters['DONE']['NON']
778 );
779 }
780 }
781
785 private function importProductBundlesAction(): void
786 {
787 $this->xmlImport->ImportProductSets();
788 $this->nextStep();
789 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_PRODUCT_BUNDLES_IMPORT_COMPLETE'));
790 }
791
795 private function finalAction(): void
796 {
797 $this->xmlImport->clearIblockCacheAfterFinal();
798 $this->iblockId = $this->stepParameters['IBLOCK_ID'];
799 $this->nextStep();
800 $this->setMessage(Loc::getMessage('IBLOCK_XML_IMPORT_MESS_FINAL_SUCCESS'));
801 $this->destroyXmlImporter();
802 $this->destroySessionStorage();
803 }
804
808 private function openXmlFile(): void
809 {
810 $this->closeXmlFile();
811
812 if ($this->fileParameters['ABSOLUTE_PATH'] == '')
813 {
814 $this->addError(Loc::getMessage('IBLOCK_XML_IMPORT_ERR_OPEN_XML_FILE'));
815
816 return;
817 }
818 $this->fileHandler = fopen($this->fileParameters['ABSOLUTE_PATH'], 'rb');
819 if (!is_resource($this->fileHandler))
820 {
821 $this->addError(Loc::getMessage('IBLOCK_XML_IMPORT_ERR_OPEN_XML_FILE'));
822
823 return;
824 }
825 $this->fileParameters['SIZE'] = (int)filesize($this->fileParameters['ABSOLUTE_PATH']);
826 if ($this->fileParameters['SIZE'] <= 0)
827 {
828 $this->addError(Loc::getMessage('IBLOCK_XML_IMPORT_ERR_OPEN_XML_FILE'));
829
830 return;
831 }
832 }
833
837 private function closeXmlFile(): void
838 {
839 if (!is_resource($this->fileHandler))
840 {
841 return;
842 }
843 fclose($this->fileHandler);
844 $this->fileHandler = null;
845 }
846
850 private function getXmlFileProgressPercent()
851 {
852 if (!is_resource($this->fileHandler))
853 {
854 return 0;
855 }
856 if ($this->fileParameters['SIZE'] <= 0)
857 {
858 return 0;
859 }
860
861 return round($this->xmlImport->GetFilePosition()*100/$this->fileParameters['SIZE'], 2);
862 }
863
867 private function createXmlImporter(): void
868 {
869 $this->xmlImport = new CIBlockCMLImport();
870 }
871
875 private function destroyXmlImporter(): void
876 {
877 if (is_object($this->xmlImport))
878 {
879 $this->xmlImport = null;
880 }
881 }
882
886 private function destroySessionStorage(): void
887 {
888 unset($this->stepId);
889 unset($this->stepParameters);
890 if (array_key_exists(self::SESSION_STORAGE_ID, $_SESSION))
891 {
892 unset($_SESSION[self::SESSION_STORAGE_ID]);
893 }
894 }
895
901 private function checkTranslitMode(int $currentValue, int $mode): bool
902 {
903 return ($currentValue & $mode) > 0;
904 }
905
909 private function getXmlImporterTransliterationSettings(): array
910 {
911 $config = $this->getConfigFieldValue('TRANSLITERATION');
912 $result = [
913 'translit_on_add' => $this->checkTranslitMode(
914 $config['MODE'],
915 self::TRANSLITERATION_ON_ADD
916 ),
917 'translit_on_update' => $this->checkTranslitMode(
918 $config['MODE'],
919 self::TRANSLITERATION_ON_UPDATE
920 ),
921 'translit_params' => [
922 'max_len' => $config['SETTINGS']['TRANS_LEN'],
923 'change_case' => $config['SETTINGS']['TRANS_CASE'],
924 'replace_space' => $config['SETTINGS']['TRANS_SPACE'],
925 'replace_other' => $config['SETTINGS']['TRANS_OTHER'],
926 'delete_repeat_replace' => $config['SETTINGS']['TRANS_EAT'] == 'Y',
927 ],
928 ];
929 unset($config);
930 return $result;
931 }
932
937 private static function clearNull($value): bool
938 {
939 return $value !== null;
940 }
941}
const IBLOCK_CACHE_FINAL
Определения cml2.php:15
init(array $parameters, array $config=[])
Определения iblockxmlimport.php:85
__construct()
Определения iblockxmlimport.php:74
const ACTION_REMOVE
Определения iblockxmlimport.php:10
clearErrors()
Определения iblockxmlimport.php:259
const TRANSLITERATION_ON_ADD
Определения iblockxmlimport.php:27
const STEP_IMPORT_PRODUCT_BUNDLES
Определения iblockxmlimport.php:21
const RESULT_TYPE_SUCCESS
Определения iblockxmlimport.php:24
getIblockId()
Определения iblockxmlimport.php:235
__destruct()
Определения iblockxmlimport.php:79
const STEP_IMPORT_ELEMENTS
Определения iblockxmlimport.php:19
const STEP_MISSING_ELEMENTS
Определения iblockxmlimport.php:20
isSuccess()
Определения iblockxmlimport.php:243
getErrors()
Определения iblockxmlimport.php:251
const STEP_IMPORT_SECTIONS
Определения iblockxmlimport.php:16
const RESULT_TYPE_ERROR
Определения iblockxmlimport.php:25
const ACTION_DEACTIVATE
Определения iblockxmlimport.php:9
const STEP_FINAL
Определения iblockxmlimport.php:22
getStepResult()
Определения iblockxmlimport.php:205
const STEP_IMPORT_METADATA
Определения iblockxmlimport.php:15
const STEP_INDEX_IMPORT_TABLES
Определения iblockxmlimport.php:14
const ACTION_NOTHING
Определения iblockxmlimport.php:8
const TRANSLITERATION_ON_UPDATE
Определения iblockxmlimport.php:28
const STEP_MISSING_SECTIONS
Определения iblockxmlimport.php:17
const STEP_INIT_IMPORT_TABLES
Определения iblockxmlimport.php:12
const STEP_RESORT_SECTIONS
Определения iblockxmlimport.php:18
isFinal()
Определения iblockxmlimport.php:151
const SESSION_STORAGE_ID
Определения iblockxmlimport.php:30
const STEP_READ_XML
Определения iblockxmlimport.php:13
$filename
Определения file_edit.php:47
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$iblockId
Определения iblock_catalog_edit.php:30
$errors
Определения iblock_catalog_edit.php:74
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$name
Определения menu_edit.php:35
$value
Определения Param.php:39
$message
Определения payment.php:8
$config
Определения quickway.php:69
$error
Определения subscription_card_product.php:20