Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ExportedProductTable.php
1<?php
2
4
9
10Loc::loadMessages(__FILE__);
11
28class ExportedProductTable extends Entity\DataManager
29{
30 public static function getTableName()
31 {
32 return 'b_catalog_exported_product';
33 }
34
35 public static function getObjectClass()
36 {
37 return ExportedProduct::class;
38 }
39
40 public static function getCollectionClass()
41 {
42 return ExportedProductCollection::class;
43 }
44
45 public static function getMap()
46 {
47 return [
48 'ID' => [
49 'data_type' => 'integer',
50 'primary' => true,
51 ],
52 'PRODUCT_ID' => [
53 'data_type' => 'integer',
54 'required' => true,
55 ],
56 'SERVICE_ID' => [
57 'data_type' => 'string',
58 'validation' => [__CLASS__, 'validateServiceId'],
59 'required' => true,
60 ],
61 'TIMESTAMP_X' => [
62 'data_type' => 'datetime',
63 'required' => true,
64 'default_value' => [__CLASS__, 'getCurrentDate'],
65 ],
66 'ERROR' => [
67 'data_type' => 'text',
68 'required' => false,
69 ],
70 ];
71 }
72
73 public static function validateServiceId(): array
74 {
75 return [
76 new LengthValidator(null, 100),
77 ];
78 }
79
80 public static function getCurrentDate(): DateTime
81 {
82 return new DateTime();
83 }
84
85 public static function deleteProduct(int $id): void
86 {
87 if ($id <= 0)
88 {
89 return;
90 }
91
92 $conn = \Bitrix\Main\Application::getConnection();
93 $helper = $conn->getSqlHelper();
94 $conn->queryExecute(
95 'delete from ' . $helper->quote(self::getTableName())
96 . ' where ' . $helper->quote('PRODUCT_ID') . ' = ' . $id
97 );
98 unset($helper, $conn);
99 }
100
101}
static loadMessages($file)
Definition loc.php:64