1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
entityimport.php
См. документацию.
1<?php
3
10
16abstract 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 {
42 }
43
48 public function setParentEntity(Sale\Order $parentEntity)
49 {
50 $this->parentEntity = $parentEntity;
51 }
52
56 public function getParentEntity()
57 {
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
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 {
130 {
131 $this->collisionErrors = true;
132 }
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
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 {
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 {
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
313 {
315 }
316
320 public static function getFieldExternalId()
321 {
322 return 'ID_1C';
323 }
324}
setParentEntity(Sale\Order $parentEntity)
Определения entityimport.php:48
__construct($parentEntityContext=null)
Определения entityimport.php:26
setCollisions($tipeId, Sale\Internals\Entity $entity, $message=null)
Определения entityimport.php:127
addMarker($order, $entity, $result)
Определения entityimport.php:197
static resolveEntityTypeId(Sale\Internals\Entity $entity)
Определения entityimport.php:312
setExternal($external=true)
Определения entityimport.php:116
setEntity(Sale\Internals\Entity $entity)
const UNDEFINED
Определения entitytype.php:7
Определения payment.php:19
static getInstance($type)
Определения registry.php:183
const REGISTRY_TYPE_ORDER
Определения registry.php:16
</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
$entity
Определения ufield.php:9
$order
Определения payment.php:8
$message
Определения payment.php:8
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
</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
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$fields
Определения yandex_run.php:501