Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
propertyvaluecollection.php
1<?php
9namespace Bitrix\Sale;
10
11use Bitrix\Main;
15
16
17Loc::loadMessages(__FILE__);
18
24{
28 protected static function getEntityType(): string
29 {
30 return \Bitrix\Sale\Registry::ENTITY_ORDER;
31 }
32
39 public function save()
40 {
41 $isChanged = $this->isChanged();
42
44 if (!$order = $this->getOrder())
45 {
46 throw new Main\ObjectNotFoundException('Entity "Order" not found');
47 }
48
49 $result = parent::save();
50
51 if ($isChanged && $order->getId() > 0)
52 {
53 $registry = Registry::getInstance(static::getRegistryType());
55 $orderHistory = $registry->getOrderHistoryClassName();
56
57 if ($result->isSuccess())
58 {
59 $orderHistory::addAction(
60 'PROPERTY',
61 $order->getId(),
62 'PROPERTY_SAVED',
63 null,
64 null,
65 [],
67 );
68 }
69
70 $orderHistory::collectEntityFields('PROPERTY', $order->getId());
71 }
72
73 return $result;
74 }
75
80 protected function callEventOnSalePropertyValueDeleted($values)
81 {
82 parent::callEventOnSalePropertyValueDeleted($values);
83
85 if (!$order = $this->getOrder())
86 {
87 throw new Main\ObjectNotFoundException('Entity "Order" not found');
88 }
89
90 if ($order->getId() > 0)
91 {
92 $registry = Registry::getInstance(static::getRegistryType());
93
95 $orderHistory = $registry->getOrderHistoryClassName();
96 $orderHistory::addAction(
97 'PROPERTY',
98 $order->getId(),
99 'PROPERTY_REMOVE',
100 $values['ID'],
101 null,
102 [
103 'NAME' => $values['NAME'],
104 'CODE' => $values['CODE'],
105 'VALUE' => $values['VALUE'],
106 ]
107 );
108 }
109 }
110
111 public static function initJs(): void
112 {
113 Input\Manager::initJs();
114 \CJSCore::RegisterExt('SaleOrderProperties', [
115 'js' => '/bitrix/js/sale/orderproperties.js',
116 'lang' => '/bitrix/modules/sale/lang/'.LANGUAGE_ID.'/lib/propertyvaluecollection.php',
117 'rel' => ['input'],
118 ]
119 );
120 \CJSCore::Init(['SaleOrderProperties']);
121 }
122}
static loadMessages($file)
Definition loc.php:64
const SALE_ORDER_HISTORY_ACTION_LOG_LEVEL_1
static getInstance($type)
Definition registry.php:183