2namespace Bitrix\Sale\Internals;
5use Bitrix\Main\Application;
6use Bitrix\Main\Localization\Loc;
8Loc::loadMessages(__FILE__);
47 return 'b_sale_discount_group';
60 'autocomplete' =>
true,
61 'title' => Loc::getMessage(
'DISCOUNT_GROUP_ENTITY_ID_FIELD')
65 'title' => Loc::getMessage(
'DISCOUNT_GROUP_ENTITY_DISCOUNT_ID_FIELD')
68 'values' =>
array(
'N',
'Y'),
69 'default_value' =>
'Y',
70 'title' => Loc::getMessage(
'DISCOUNT_GROUP_ENTITY_ACTIVE_FIELD')
74 'title' => Loc::getMessage(
'DISCOUNT_GROUP_ENTITY_GROUP_ID_FIELD')
78 'Bitrix\Sale\Internals\Discount',
79 array(
'=this.DISCOUNT_ID' =>
'ref.ID'),
80 array(
'join_type' =>
'LEFT')
96 $conn = Application::getConnection();
97 $helper = $conn->getSqlHelper();
99 'delete from '.$helper->quote(self::getTableName()).
' where '.$helper->quote(
'DISCOUNT_ID').
' = '.
$discount
117 $clear = ($clear ===
true);
122 if (is_array($groupList))
124 $active = (string)$active;
125 if ($active !=
'Y' && $active !=
'N')
127 $discountIterator = self::getList(
array(
128 'select' =>
array(
'ACTIVE'),
131 if ($discountActive = $discountIterator->fetch())
133 $active = $discountActive[
'ACTIVE'];
135 unset($discountActive, $discountIterator);
137 if ($active ==
'Y' || $active ==
'N')
139 if (empty($groupList))
142 foreach ($groupList as &$group)
167 $active = (string)$active;
168 if (
$discount <= 0 || ($active !=
'Y' && $active !=
'N'))
170 $conn = Application::getConnection();
171 $helper = $conn->getSqlHelper();
173 'update '.$helper->quote(self::getTableName()).
174 ' set '.$helper->quote(
'ACTIVE').
' = \''.$active.
'\' where
'.
175 $helper->quote('DISCOUNT_ID
').' =
'.$discount
186 public static function getDiscountByGroups($groupList, $filter = array())
189 if (!empty($groupList) && is_array($groupList))
191 Main\Type\Collection::normalizeArrayValuesByInt($groupList);
192 if (!empty($groupList))
194 if (!is_array($filter))
197 $groupRows = array_chunk($groupList, 500);
198 foreach ($groupRows as &$row)
200 $filter['@GROUP_ID
'] = $row;
202 $groupIterator = self::getList(array(
203 'select' => array('DISCOUNT_ID
'),
206 while ($group = $groupIterator->fetch())
208 $group['DISCOUNT_ID
'] = (int)$group['DISCOUNT_ID
'];
209 $result[$group['DISCOUNT_ID
']] = true;
211 unset($group, $groupIterator);
213 unset($row, $groupRows);
215 $result = array_keys($result);
227 public static function getActiveDiscountByGroups($groupList)
229 return self::getDiscountByGroups($groupList, array('ACTIVE
' => 'Y
'));
static deleteByDiscount($discount)
static updateByDiscount($discount, $groupList, $active, $clear)
static changeActiveByDiscount($discount, $active)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)