Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
handler.php
1<?php
3
4
9
10final class Handler
11{
12 static public function handlerCallbackOnSaleOrderSaved(Event $event)
13 {
15 $order = $event->getParameters()['ENTITY'];
16
17 if((new Integration\Connector\Manager())->isOn())
18 {
19 if($order->isNew())
20 {
21 $fields = new \Bitrix\Sale\Internals\Fields(
23 ->getRequest()
24 ->toArray());
25
26 $placement = new Integration\CRM\Placement\PlacementDeal($fields->getValues());
27 if($placement->getTypeHandler() == Integration\HandlerType::ORDER_NEW) //deal exists + new order
28 {
29
30 if($fields->get('entityTypeId') == Integration\CRM\EntityType::DEAL
31 && $fields->get('entityId')>0)
32 {
33 $params[$order->getId()] = [
34 'OWNER_TYPE_ID'=>Integration\CRM\EntityType::DEAL,
35 'OWNER_ID'=>$fields->get('entityId')
36 ];
37
39 ->update($fields->get('entityId'), $params);
40
41 (new static())
42 ->syncB24($order);
43 }
44 }
45 else //new deal + new order
46 {
47 /*
48 (new Integration\Service\Scenarios\DealAdd())
49 ->adds([$order->getId()=>$order->getFieldValues()]);
50
51 (new static())
52 ->syncB24($order);
53 */
54 }
55 }
56 }
57
58 }
59 static public function syncB24(Order $order)
60 {
61 $order->setFieldNoDemand('IS_SYNC_B24', 'Y');
62
63 OrderTable::update($order->getId(), ['IS_SYNC_B24' => 'Y']);
64 }
65}
static getCurrent()
Definition context.php:241
setFieldNoDemand($name, $value)