Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
basketarchive.php
1<?php
9
10use Bitrix\Main;
11
28class BasketArchiveTable extends Main\Entity\DataManager
29{
35 public static function getTableName()
36 {
37 return 'b_sale_basket_archive';
38 }
39
45 public static function getMap()
46 {
47 return array(
48 new Main\Entity\IntegerField(
49 'ID',
50 array(
51 'autocomplete' => true,
52 'primary' => true,
53 )
54 ),
55
56 new Main\Entity\IntegerField(
57 'ARCHIVE_ID',
58 array(
59 'required' => true,
60 )
61 ),
62
63 new Main\Entity\IntegerField(
64 'PRODUCT_ID',
65 array(
66 'required' => true,
67 )
68 ),
69
70 new Main\Entity\IntegerField('PRODUCT_PRICE_ID'),
71
72 new Main\Entity\StringField(
73 'NAME',
74 array(
75 'size' => 255,
76 'required' => true,
77 )
78 ),
79
80
81 new Main\Entity\FloatField(
82 'PRICE',
83 array(
84 'default_value' => '0.0000'
85 )
86 ),
87
88 new Main\Entity\StringField('MODULE'),
89
90 new Main\Entity\FloatField(
91 'QUANTITY',
92 array(
93 'default_value' => '0.0000'
94 )
95 ),
96
97 new Main\Entity\FloatField(
98 'WEIGHT',
99 array(
100 'default_value' => '0.0000'
101 )
102 ),
103
104 new Main\Entity\StringField(
105 'CURRENCY',
106 array(
107 'required' => true,
108 'size' => 3
109 )
110 ),
111
112 new Main\Entity\StringField(
113 'PRODUCT_XML_ID',
114 array(
115 'size' => 100
116 )
117 ),
118
119 new Main\Entity\StringField(
120 'MEASURE_NAME',
121 array(
122 'size' => 50
123 )
124 ),
125
126 new Main\Entity\IntegerField('TYPE'),
127
128 new Main\Entity\IntegerField('SET_PARENT_ID'),
129
130 new Main\Entity\IntegerField('MEASURE_CODE'),
131
132 new Main\Entity\DatetimeField('DATE_INSERT'),
133
134 new Main\Entity\StringField('BASKET_DATA'),
135
136 new Main\Entity\ReferenceField(
137 'BASKET_PACKED',
138 'Bitrix\Sale\Internals\BasketArchivePacked',
139 array('=this.ID' => 'ref.BASKET_ARCHIVE_ID'),
140 array('join_type' => 'INNER')
141 )
142 );
143 }
144
162 public static function add(array $data)
163 {
164 $basketData = $data['BASKET_DATA'];
165 unset($data['BASKET_DATA']);
166
167 $result = parent::add($data);
168
169 if ($result->isSuccess())
170 {
171 BasketArchivePackedTable::add(array(
172 "BASKET_ARCHIVE_ID" => $result->getId(),
173 "BASKET_DATA" => $basketData
174 ));
175 }
176
177 return $result;
178 }
179
189 public static function delete($primary)
190 {
191 $result = parent::delete($primary);
192
193 if ($result->isSuccess())
194 {
195 $checkOrderData = BasketArchivePackedTable::getById($primary);
196 if ($checkOrderData->fetch())
197 {
198 BasketArchivePackedTable::delete($primary);
199 }
200 }
201
202 return $result;
203 }
204}