Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
productgroupaccess.php
1<?php
2namespace Bitrix\Catalog;
3
6Loc::loadMessages(__FILE__);
7
37class ProductGroupAccessTable extends Main\Entity\DataManager
38{
39 const ACCESS_LENGTH_HOUR = 'H';
40 const ACCESS_LENGTH_DAY = 'D';
41 const ACCESS_LENGTH_WEEK = 'W';
45 const ACCESS_LENGTH_YEAR = 'Y';
46
52 public static function getTableName()
53 {
54 return 'b_catalog_product2group';
55 }
56
62 public static function getMap()
63 {
64 return array(
65 'ID' => new Main\Entity\IntegerField('ID', array(
66 'primary' => true,
67 'autocomplete' => true,
68 'title' => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ID_FIELD')
69 )),
70 'PRODUCT_ID' => new Main\Entity\IntegerField('PRODUCT_ID', array(
71 'required' => true,
72 'title' => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_PRODUCT_ID_FIELD')
73 )),
74 'GROUP_ID' => new Main\Entity\IntegerField('GROUP_ID', array(
75 'required' => true,
76 'title' => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_GROUP_ID_FIELD')
77 )),
78 'ACCESS_LENGTH' => new Main\Entity\IntegerField('ACCESS_LENGTH', array(
79 'required' => true,
80 'title' => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_FIELD')
81 )),
82 'ACCESS_LENGTH_TYPE' => new Main\Entity\EnumField('ACCESS_LENGTH_TYPE', array(
83 'required' => true,
84 'values' => static::getAccessPeriods(false),
85 'default_value' => self::ACCESS_LENGTH_DAY,
86 'title' => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_TYPE_FIELD')
87 )),
88 'PRODUCT' => new Main\Entity\ReferenceField(
89 'PRODUCT',
90 '\Bitrix\Catalog\Product',
91 array('=this.PRODUCT_ID' => 'ref.ID'),
92 array('join_type' => 'LEFT')
93 )
94 );
95 }
96
103 public static function getAccessPeriods($descr = false)
104 {
105 if ($descr)
106 {
107 return array(
108 self::ACCESS_LENGTH_HOUR => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_HOUR'),
109 self::ACCESS_LENGTH_DAY => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_DAY'),
110 self::ACCESS_LENGTH_WEEK => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_WEEK'),
111 self::ACCESS_LENGTH_MONTH => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_MONTH'),
112 self::ACCESS_LENGTH_QUART => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_QUART'),
113 self::ACCESS_LENGTH_SEMIYEAR => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_SEMIYEAR'),
114 self::ACCESS_LENGTH_YEAR => Loc::getMessage('PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_YEAR')
115 );
116 }
117 return array(
118 self::ACCESS_LENGTH_HOUR,
119 self::ACCESS_LENGTH_DAY,
120 self::ACCESS_LENGTH_WEEK,
121 self::ACCESS_LENGTH_MONTH,
122 self::ACCESS_LENGTH_QUART,
123 self::ACCESS_LENGTH_SEMIYEAR,
124 self::ACCESS_LENGTH_YEAR
125 );
126 }
127
135 public static function deleteByProduct($id)
136 {
137 $id = (int)$id;
138 if ($id <= 0)
139 return;
140
141 $conn = Main\Application::getConnection();
142 $helper = $conn->getSqlHelper();
143 $conn->queryExecute(
144 'delete from '.$helper->quote(self::getTableName()).' where '.$helper->quote('PRODUCT_ID').' = '.$id
145 );
146 unset($helper, $conn);
147 }
148}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29