1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
entityimport.php
См. документацию.
1
<?php
2
namespace
Bitrix\Sale\Exchange\Entity
;
3
4
use
Bitrix\Main
;
5
use
Bitrix\Sale
;
6
use
Bitrix\Sale\Shipment
;
7
use
Bitrix\Sale\Payment
;
8
use
Bitrix\Sale\Exchange
;
9
use
Bitrix\Sale\EntityMarker
;
10
16
abstract
class
EntityImport
extends
Exchange\ImportBase
17
{
18
public
$collisions
=
array
();
19
20
protected
$parentEntity
=
null
;
22
protected
$entity
=
null
;
23
protected
$external
=
null
;
24
protected
$marked
=
false
;
25
26
public
function
__construct
($parentEntityContext =
null
)
27
{
28
$this->fields =
new
Sale\Internals\Fields
();
29
30
if
(!empty($parentEntityContext))
31
{
32
$this->
setParentEntity
($parentEntityContext);
33
}
34
}
35
39
public
function
getOwnerTypeId
()
40
{
41
return
Exchange\EntityType::UNDEFINED
;
42
}
43
48
public
function
setParentEntity
(
Sale
\Order
$parentEntity
)
49
{
50
$this->parentEntity =
$parentEntity
;
51
}
52
56
public
function
getParentEntity
()
57
{
58
return
$this->parentEntity
;
59
}
60
64
public
function
isLoadedParentEntity
()
65
{
66
$order
= $this->
getParentEntity
();
67
return
$order
instanceof Sale\Order;
68
}
69
74
protected
function
loadParentEntity(
array
$fields
)
75
{
76
$entity
=
null
;
77
78
if
(!empty(
$fields
[
'ID'
]))
79
{
80
81
$registry =
Sale\Registry::getInstance
(
Sale
\
Registry::REGISTRY_TYPE_ORDER
);
83
$orderClass = $registry->getOrderClassName();
84
86
$entity
= $orderClass::load(
$fields
[
'ID'
]);
87
}
88
return
$entity
;
89
}
90
95
abstract
public
function
setEntity
(
Sale
\
Internals
\
Entity
$entity
);
96
100
public
function
getEntity
()
101
{
102
return
$this->entity
;
103
}
104
108
protected
function
isExternal
()
109
{
110
return
$this->external
;
111
}
112
116
public
function
setExternal
(
$external
=
true
)
117
{
118
$this->external =
$external
;
119
}
120
127
public
function
setCollisions
($tipeId,
Sale
\
Internals
\
Entity
$entity
,
$message
=
null
)
128
{
129
if
(
Exchange
\
EntityCollisionType::getErrorGroup
($tipeId) ==
Exchange
\
EntityCollisionType::GROUP_E_ERROR
)
130
{
131
$this->collisionErrors =
true
;
132
}
133
elseif
(
Exchange
\
EntityCollisionType::getErrorGroup
($tipeId) ==
Exchange
\
EntityCollisionType::GROUP_E_WARNING
)
134
{
135
$this->collisionWarnings =
true
;
136
}
137
138
$collision = $this->getCurrentCollision($this->
getOwnerTypeId
());
139
$collision->addItem($this->
getOwnerTypeId
(), $tipeId,
$entity
,
$message
);
140
141
$this->collisions[] = $collision;
142
}
143
147
public
function
getCollisions
()
148
{
149
return
$this->collisions
;
150
}
151
155
public
function
hasCollisions
()
156
{
157
return
(
count
($this->collisions));
158
}
159
163
public
function
markedEntityCollisions(
$collisions
)
164
{
166
$entity
= $this->
getEntity
();
167
169
$parentEntity
= $this->
getParentEntity
();
170
172
foreach
(
$collisions
as $collision)
173
{
174
$result
=
new
Sale\Result
();
175
$result
->addWarning(
new
Sale
\
ResultError
(
Exchange
\
EntityCollisionType::getDescription
($collision->getTypeId()).($collision->getMessage() !=
null
?
" "
.$collision->getMessage():
''
), $collision->getTypeName()));
176
177
$entity
->setField(
'MARKED'
,
'Y'
);
178
$this->marked =
true
;
179
180
$collisionEntity = $collision->getEntity();
181
if
(!empty($collisionEntity))
182
{
183
$this->
addMarker
(
$parentEntity
, $collisionEntity,
$result
);
184
}
185
else
186
{
187
$this->
addMarker
(
$parentEntity
,
$entity
,
$result
);
188
}
189
}
190
}
191
197
protected
function
addMarker
(
$order
,
$entity
,
$result
)
198
{
199
EntityMarker::addMarker(
$order
,
$entity
,
$result
);
200
}
201
205
public
function
isMarked
()
206
{
207
return
$this->marked
;
208
}
209
213
public
function
getId
()
214
{
215
return
$this->getEntityId();
216
}
217
223
public
function
isImportable
()
224
{
225
return
$this->settings->isImportableFor($this->
getOwnerTypeId
());
226
}
227
233
public
function
import
(
array
$params
)
234
{
235
$result
= parent::import(
$params
);
236
if
(
$result
->isSuccess())
237
{
239
if
((
$entity
= $this->
getEntity
()))
240
$this->marked(
$entity
,
$params
[
'TRAITS'
]);
241
}
242
return
$result
;
243
}
244
248
abstract
public
function
save
();
249
256
function
marked(
Sale
\
Internals
\
Entity
$entity
,
array
$fields
)
257
{
258
if
($this->
isExternal
())
259
$entity->setField($this->
getExternalFieldName
(),
'Y'
);
260
else
261
$entity->setField(
'UPDATED_1C'
,
'Y'
);
262
263
if
(!$this->
hasCollisions
())
264
{
265
$entity->setField(
'VERSION_1C'
,
$fields
[
'VERSION_1C'
]);
266
}
267
268
$entity
->setField(
'ID_1C'
,
$fields
[
'ID_1C'
]);
269
270
if
(!(
$entity
instanceof
Sale
\Order))
271
{
273
$parentEntity
= $this->
getParentEntity
();
274
275
$parentEntity
->setField(
'UPDATED_1C'
,
'Y'
);
276
}
277
}
278
282
public
function
getEntityId()
283
{
284
$entity
= $this->
getEntity
();
285
if
(!empty(
$entity
))
286
{
288
return
$entity
->getId();
289
}
290
291
return
null
;
292
}
293
298
protected
function
checkEntity
($id)
299
{
300
return
is_int($id) && $id > 0;
301
}
302
306
abstract
protected
function
getExternalFieldName
();
307
312
public
static
function
resolveEntityTypeId
(
Sale
\
Internals
\
Entity
$entity
)
313
{
314
return
Exchange\EntityType::UNDEFINED
;
315
}
316
320
public
static
function
getFieldExternalId
()
321
{
322
return
'ID_1C'
;
323
}
324
}
Bitrix\Sale\EntityMarker
Определения
entitymarker.php:14
Bitrix\Sale\Exchange\Entity\EntityImport
Определения
entityimport.php:17
Bitrix\Sale\Exchange\Entity\EntityImport\getEntity
getEntity()
Определения
entityimport.php:100
Bitrix\Sale\Exchange\Entity\EntityImport\setParentEntity
setParentEntity(Sale\Order $parentEntity)
Определения
entityimport.php:48
Bitrix\Sale\Exchange\Entity\EntityImport\getExternalFieldName
getExternalFieldName()
Bitrix\Sale\Exchange\Entity\EntityImport\getId
getId()
Определения
entityimport.php:213
Bitrix\Sale\Exchange\Entity\EntityImport\$parentEntity
$parentEntity
Определения
entityimport.php:20
Bitrix\Sale\Exchange\Entity\EntityImport\getParentEntity
getParentEntity()
Определения
entityimport.php:56
Bitrix\Sale\Exchange\Entity\EntityImport\__construct
__construct($parentEntityContext=null)
Определения
entityimport.php:26
Bitrix\Sale\Exchange\Entity\EntityImport\getCollisions
getCollisions()
Определения
entityimport.php:147
Bitrix\Sale\Exchange\Entity\EntityImport\setCollisions
setCollisions($tipeId, Sale\Internals\Entity $entity, $message=null)
Определения
entityimport.php:127
Bitrix\Sale\Exchange\Entity\EntityImport\$marked
$marked
Определения
entityimport.php:24
Bitrix\Sale\Exchange\Entity\EntityImport\hasCollisions
hasCollisions()
Определения
entityimport.php:155
Bitrix\Sale\Exchange\Entity\EntityImport\$external
$external
Определения
entityimport.php:23
Bitrix\Sale\Exchange\Entity\EntityImport\addMarker
addMarker($order, $entity, $result)
Определения
entityimport.php:197
Bitrix\Sale\Exchange\Entity\EntityImport\$entity
$entity
Определения
entityimport.php:22
Bitrix\Sale\Exchange\Entity\EntityImport\checkEntity
checkEntity($id)
Определения
entityimport.php:298
Bitrix\Sale\Exchange\Entity\EntityImport\isExternal
isExternal()
Определения
entityimport.php:108
Bitrix\Sale\Exchange\Entity\EntityImport\isImportable
isImportable()
Определения
entityimport.php:223
Bitrix\Sale\Exchange\Entity\EntityImport\resolveEntityTypeId
static resolveEntityTypeId(Sale\Internals\Entity $entity)
Определения
entityimport.php:312
Bitrix\Sale\Exchange\Entity\EntityImport\$collisions
$collisions
Определения
entityimport.php:18
Bitrix\Sale\Exchange\Entity\EntityImport\getOwnerTypeId
getOwnerTypeId()
Определения
entityimport.php:39
Bitrix\Sale\Exchange\Entity\EntityImport\getFieldExternalId
static getFieldExternalId()
Определения
entityimport.php:320
Bitrix\Sale\Exchange\Entity\EntityImport\setExternal
setExternal($external=true)
Определения
entityimport.php:116
Bitrix\Sale\Exchange\Entity\EntityImport\isLoadedParentEntity
isLoadedParentEntity()
Определения
entityimport.php:64
Bitrix\Sale\Exchange\Entity\EntityImport\isMarked
isMarked()
Определения
entityimport.php:205
Bitrix\Sale\Exchange\Entity\EntityImport\setEntity
setEntity(Sale\Internals\Entity $entity)
Bitrix\Sale\Exchange\Entity\EntityImport\save
save()
Bitrix\Sale\Exchange\EntityCollisionType\getErrorGroup
static getErrorGroup($typeId)
Определения
entitycollisiontype.php:345
Bitrix\Sale\Exchange\EntityCollisionType\getDescription
static getDescription($typeId)
Определения
entitycollisiontype.php:274
Bitrix\Sale\Exchange\EntityCollisionType\GROUP_E_ERROR
const GROUP_E_ERROR
Определения
entitycollisiontype.php:10
Bitrix\Sale\Exchange\EntityCollisionType\GROUP_E_WARNING
const GROUP_E_WARNING
Определения
entitycollisiontype.php:11
Bitrix\Sale\Exchange\EntityType\UNDEFINED
const UNDEFINED
Определения
entitytype.php:7
Bitrix\Sale\Exchange\ImportBase
Определения
importbase.php:9
Bitrix\Sale\Exchange\ImportBase\$fields
$fields
Определения
importbase.php:18
Bitrix\Sale\Payment
Определения
payment.php:19
Bitrix\Sale\Registry\getInstance
static getInstance($type)
Определения
registry.php:183
Bitrix\Sale\Registry\REGISTRY_TYPE_ORDER
const REGISTRY_TYPE_ORDER
Определения
registry.php:16
Bitrix\Sale\ResultError
Определения
result.php:161
Bitrix\Sale\Shipment
Определения
shipment.php:21
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$entity
$entity
Определения
group_bizproc_workflow_delete.php:17
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Main\ORM\Fields
Определения
arrayfield.php:9
Bitrix\Main
Bitrix\Sale\Cashbox\Internals
Bitrix\Sale\Discount\Result
Определения
compatibleformat.php:2
Bitrix\Sale\Exchange\Entity
Определения
entityimport.php:2
Bitrix\Sale\Exchange
Определения
basetrait.php:2
Bitrix\Sale
$order
$order
Определения
payment.php:8
$message
$message
Определения
payment.php:8
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
count
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения
waybill.php:936
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
sale
lib
exchange
entity
entityimport.php
Создано системой
1.14.0