Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
migration.php
1
<?
9
namespace
Bitrix\Sale\Location\Migration
;
10
11
use
Bitrix\Main
;
12
use
Bitrix\Sale\Location
;
13
14
include_once($_SERVER[
"DOCUMENT_ROOT"
].
"/bitrix/modules/sale/lib/location/migration/migrate.php"
);
15
16
final
class
MigrationProcess
extends
Location\Util\Process
17
{
18
const
SESS_KEY
=
'location_migration'
;
19
const
NOTIF_TAG
=
'SALE_LOCATIONPRO_PLZ_MIGRATE'
;
20
21
private
$migrator =
null
;
22
23
public
function
__construct
()
24
{
25
parent::__construct();
26
27
$this->
addStage
(array(
28
'PERCENT'
=> 10,
29
'CODE'
=>
'CREATE_TYPES'
,
30
'CALLBACK'
=>
'stageCreateTypes'
31
));
32
33
$this->
addStage
(array(
34
'PERCENT'
=> 30,
35
'CODE'
=>
'CONVERT_TREE'
,
36
'CALLBACK'
=>
'stageConvertTree'
37
));
38
39
$this->
addStage
(array(
40
'PERCENT'
=> 50,
41
'CODE'
=>
'CONVERT_ZONES'
,
42
'CALLBACK'
=>
'stageConvertZones'
43
));
44
45
$this->
addStage
(array(
46
'PERCENT'
=> 70,
47
'CODE'
=>
'CONVERT_LINKS'
,
48
'CALLBACK'
=>
'stageConvertLinks'
49
));
50
51
$this->
addStage
(array(
52
'PERCENT'
=> 90,
53
'STEP_SIZE'
=> 1,
54
'CODE'
=>
'COPY_DEFAULT_LOCATIONS'
,
55
'CALLBACK'
=>
'stageCopyDefaultLocations'
56
));
57
58
$this->
addStage
(array(
59
'PERCENT'
=> 100,
60
'STEP_SIZE'
=> 1,
61
'CODE'
=>
'COPY_ZIP_CODES'
,
62
'CALLBACK'
=>
'stageCopyZipCodes'
63
));
64
}
65
66
public
function
onBeforePerformIteration
()
67
{
68
if
(\CSaleLocation::isLocationProMigrated())
69
throw
new
Main\SystemException
(
'Already migrated'
);
70
71
if
(!isset($this->data[
'migrator_data'
]))
72
$this->migrator =
new
CUpdaterLocationPro
();
73
else
74
$this->migrator = unserialize($this->data[
'migrator_data'
], [
'allowed_classes'
=>
false
]);
75
}
76
77
public
function
onAfterPerformIteration
()
78
{
79
$this->data[
'migrator_data'
] = serialize($this->migrator);
80
if
($this->
getPercent
() == 100)
81
{
82
\CSaleLocation::locationProSetMigrated();
83
\CSaleLocation::locationProEnable();
84
}
85
}
86
87
protected
function
stageCreateTypes
()
88
{
89
$this->migrator->createTypes();
90
$this->
nextStage
();
91
}
92
93
protected
function
stageConvertTree
()
94
{
95
if
($this->
getStep
() == 0)
96
{
97
$this->migrator->convertTree();
98
$this->
nextStep
();
99
}
100
else
101
{
102
$this->migrator->resetLegacyPath();
103
$this->
nextStage
();
104
}
105
}
106
107
protected
function
stageConvertZones
()
108
{
109
$this->migrator->convertSalesZones();
110
$this->
nextStage
();
111
}
112
113
protected
function
stageConvertLinks
()
114
{
115
$this->migrator->convertGroupLocationLinks();
116
$this->migrator->convertDeliveryLocationLinks();
117
$this->migrator->convertTaxRateLocationLinks();
118
$this->
nextStage
();
119
}
120
121
protected
function
stageCopyDefaultLocations
()
122
{
123
$this->migrator->copyDefaultLocations();
124
$this->
nextStage
();
125
}
126
127
protected
function
stageCopyZipCodes
()
128
{
129
$this->migrator->copyZipCodes();
130
$this->
nextStage
();
131
}
132
133
public
function
hideNotifier
()
134
{
135
\CAdminNotify::DeleteByTag(
136
self::NOTIF_TAG
137
);
138
}
139
}
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Sale\Location\Migration\CUpdaterLocationPro
Definition
migrate.php:20
Bitrix\Sale\Location\Migration\MigrationProcess
Definition
migration.php:17
Bitrix\Sale\Location\Migration\MigrationProcess\__construct
__construct()
Definition
migration.php:23
Bitrix\Sale\Location\Migration\MigrationProcess\stageConvertLinks
stageConvertLinks()
Definition
migration.php:113
Bitrix\Sale\Location\Migration\MigrationProcess\stageCopyDefaultLocations
stageCopyDefaultLocations()
Definition
migration.php:121
Bitrix\Sale\Location\Migration\MigrationProcess\hideNotifier
hideNotifier()
Definition
migration.php:133
Bitrix\Sale\Location\Migration\MigrationProcess\SESS_KEY
const SESS_KEY
Definition
migration.php:18
Bitrix\Sale\Location\Migration\MigrationProcess\stageCopyZipCodes
stageCopyZipCodes()
Definition
migration.php:127
Bitrix\Sale\Location\Migration\MigrationProcess\stageConvertTree
stageConvertTree()
Definition
migration.php:93
Bitrix\Sale\Location\Migration\MigrationProcess\NOTIF_TAG
const NOTIF_TAG
Definition
migration.php:19
Bitrix\Sale\Location\Migration\MigrationProcess\stageConvertZones
stageConvertZones()
Definition
migration.php:107
Bitrix\Sale\Location\Migration\MigrationProcess\stageCreateTypes
stageCreateTypes()
Definition
migration.php:87
Bitrix\Sale\Location\Migration\MigrationProcess\onAfterPerformIteration
onAfterPerformIteration()
Definition
migration.php:77
Bitrix\Sale\Location\Migration\MigrationProcess\onBeforePerformIteration
onBeforePerformIteration()
Definition
migration.php:66
Bitrix\Sale\Location\Util\Process
Definition
process.php:14
Bitrix\Sale\Location\Util\Process\addStage
addStage($params)
Definition
process.php:67
Bitrix\Sale\Location\Util\Process\getPercent
getPercent()
Definition
process.php:362
Bitrix\Sale\Location\Util\Process\nextStage
nextStage()
Definition
process.php:221
Bitrix\Sale\Location\Util\Process\getStep
getStep()
Definition
process.php:308
Bitrix\Sale\Location\Util\Process\nextStep
nextStep()
Definition
process.php:243
Bitrix\Main
Bitrix\Sale\Location\Migration
Definition
migrate.php:3
Bitrix\Sale\Location
modules
sale
lib
location
migration
migration.php
Создано системой
1.10.0