Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
discountrestriction.php
1<?php
2namespace Bitrix\Catalog;
3
6
7Loc::loadMessages(__FILE__);
8
37class DiscountRestrictionTable extends Main\Entity\DataManager
38{
44 public static function getTableName()
45 {
46 return 'b_catalog_discount_cond';
47 }
48
54 public static function getMap()
55 {
56 return array(
57 'ID' => new Main\Entity\IntegerField('ID', array(
58 'primary' => true,
59 'autocomplete' => true,
60 'title' => Loc::getMessage('DISCOUNT_RESTRICTIONS_ENTITY_ID_FIELD')
61 )),
62 'DISCOUNT_ID' => new Main\Entity\IntegerField('DISCOUNT_ID', array(
63 'required' => true,
64 'title' => Loc::getMessage('DISCOUNT_RESTRICTIONS_ENTITY_DISCOUNT_ID_FIELD')
65 )),
66 'ACTIVE' => new Main\Entity\BooleanField('ACTIVE', array(
67 'values' => array('N', 'Y'),
68 'title' => Loc::getMessage('DISCOUNT_RESTRICTIONS_ENTITY_ACTIVE_FIELD')
69 )),
70 'USER_GROUP_ID' => new Main\Entity\IntegerField('USER_GROUP_ID', array(
71 'required' => true,
72 'title' => Loc::getMessage('DISCOUNT_RESTRICTIONS_ENTITY_USER_GROUP_ID_FIELD')
73 )),
74 'PRICE_TYPE_ID' => new Main\Entity\IntegerField('PRICE_TYPE_ID', array(
75 'required' => true,
76 'title' => Loc::getMessage('DISCOUNT_RESTRICTIONS_ENTITY_PRICE_TYPE_ID_FIELD')
77 )),
78 'DISCOUNT' => new Main\Entity\ReferenceField(
79 'DISCOUNT',
80 '\Bitrix\Catalog\Discount',
81 array('=this.DISCOUNT_ID' => 'ref.ID')
82 )
83 );
84 }
85
93 public static function changeActiveByDiscount($discount, $active)
94 {
95 $discount = (int)$discount;
96 $active = (string)$active;
97 if ($discount <= 0 || ($active != 'Y' && $active != 'N'))
98 return;
99 $conn = Main\Application::getConnection();
100 $helper = $conn->getSqlHelper();
101 $conn->queryExecute(
102 'update '.$helper->quote(self::getTableName()).
103 ' set '.$helper->quote('ACTIVE').' = \''.$active.'\' where '.
104 $helper->quote('DISCOUNT_ID').' = '.$discount
105 );
106 unset($helper, $conn);
107 }
108
115 public static function deleteByDiscount($discount)
116 {
117 $discount = (int)$discount;
118 if ($discount <= 0)
119 return;
120 $conn = Main\Application::getConnection();
121 $helper = $conn->getSqlHelper();
122 $conn->queryExecute(
123 'delete from '.$helper->quote(self::getTableName()).' where '.$helper->quote('DISCOUNT_ID').' = '.$discount
124 );
125 unset($helper, $conn);
126 }
127}
static changeActiveByDiscount($discount, $active)
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29