1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
feature.php
См. документацию.
1<?php
2namespace Bitrix\Catalog\Config;
3
4use Bitrix\Bitrix24;
5use Bitrix\Catalog\Store\EnableWizard;
6use Bitrix\Main;
7use Bitrix\Main\Config\Option;
8use Bitrix\Main\Loader;
9
16final class Feature
17{
18 private const PRODUCT_SETS = 'catalog_product_sets';
19 private const MULTI_PRICE_TYPES = 'catalog_multi_price_types';
20 private const CUMULATIVE_DISCOUNTS = 'catalog_cumulative_discounts';
21 private const MULTI_WARENHOUSES = 'catalog_multi_warenhouses';
22 private const EXTENDED_PRICES = 'catalog_price_quantity_ranges';
23 private const INVENTORY_MANAGEMENT = 'catalog_inventory_management';
24 private const INVENTORY_MANAGEMENT_1C = 'catalog_inventory_management_1c';
25 private const COMMON_PRODUCT_PROCESSING = 'catalog_common_product_processing';
26 private const PRODUCT_LIMIT = 'catalog_product_limit';
27 private const CATALOG_PERMISSIONS = 'catalog_permissions';
28 private const CATALOG_SERVICES = 'catalog_services';
29
30 private const LANDING_PRODUCT_LIMIT_VARIABLE = 'landing_product_limit';
31
33 private static ?bool $bitrix24Included = null;
34
36 private static array $tranferList = [
37 self::PRODUCT_SETS => 'CatCompleteSet',
38 self::MULTI_PRICE_TYPES => 'CatMultiPrice',
39 self::CUMULATIVE_DISCOUNTS => 'CatDiscountSave',
40 self::MULTI_WARENHOUSES => 'CatMultiStore'
41 ];
42
44 private static array $retailExist = [
45 self::PRODUCT_SETS => true,
46 self::MULTI_PRICE_TYPES => true,
47 self::CUMULATIVE_DISCOUNTS => true,
48 self::MULTI_WARENHOUSES => true
49 ];
50
52 private static array $bitrix24exist = [
53 self::PRODUCT_SETS => true,
54 self::EXTENDED_PRICES => true,
55 self::MULTI_PRICE_TYPES => true,
56 self::MULTI_WARENHOUSES => true,
57 self::INVENTORY_MANAGEMENT => true,
58 self::INVENTORY_MANAGEMENT_1C => true,
59 self::COMMON_PRODUCT_PROCESSING => true,
60 self::CATALOG_PERMISSIONS => true,
61 self::CATALOG_SERVICES => true,
62 ];
63
65 private static array $bitrix24helpCodes = [
66 self::PRODUCT_SETS => 'limit_shop_bundles',
67 self::MULTI_PRICE_TYPES => 'limit_shop_variable_prices',
68 self::EXTENDED_PRICES => 'limit_shop_variable_prices',
69 self::MULTI_WARENHOUSES => 'limit_shop_stocks',
70 self::INVENTORY_MANAGEMENT => 'limit_store_inventory_management',
71 self::PRODUCT_LIMIT => 'limit_shop_products',
72 self::CATALOG_PERMISSIONS => 'limit_crm_catalog_access_permissions',
73 self::CATALOG_SERVICES => 'limit_crm_catalog_services',
74 ];
75
76 private static int $helpCodesCounter = 0;
77 private static bool $initUi = false;
78
82 public static function getLandingProductLimit(): int
83 {
84 $result = 0;
85 if (self::isBitrix24())
86 {
87 $result = (int)Bitrix24\Feature::getVariable(self::LANDING_PRODUCT_LIMIT_VARIABLE);
88 }
89
90 return $result;
91 }
92
98 public static function isProductSetsEnabled(): bool
99 {
100 return self::isFeatureEnabled(self::PRODUCT_SETS);
101 }
102
108 public static function isPriceQuantityRangesEnabled(): bool
109 {
110 return self::isFeatureEnabled(self::EXTENDED_PRICES);
111 }
112
118 public static function isMultiPriceTypesEnabled(): bool
119 {
120 return self::isFeatureEnabled(self::MULTI_PRICE_TYPES);
121 }
122
128 public static function isCumulativeDiscountsEnabled(): bool
129 {
130 return self::isFeatureEnabled(self::CUMULATIVE_DISCOUNTS);
131 }
132
138 public static function isMultiStoresEnabled(): bool
139 {
140 return self::isFeatureEnabled(self::MULTI_WARENHOUSES);
141 }
142
148 public static function isInventoryManagementEnabled(): bool
149 {
150 return self::isFeatureEnabled(self::INVENTORY_MANAGEMENT);
151 }
152
153 public static function checkInventoryManagementFeatureByCurrentMode(): bool
154 {
156
157 if ($currentMode === EnableWizard\ModeList::ONEC)
158 {
160 }
161
163 }
164
170 public static function isCommonProductProcessingEnabled(): bool
171 {
172 if (!self::isBitrix24())
173 {
174 return Option::get('catalog', 'catalog_common_product_processing') === 'Y';
175 }
176
177 return self::isFeatureEnabled(self::COMMON_PRODUCT_PROCESSING);
178 }
179
185 public static function isAccessControllerCheckingEnabled(): bool
186 {
187 return self::isFeatureEnabled(self::CATALOG_PERMISSIONS);
188 }
189
195 public static function isCanUseYandexExport(): bool
196 {
197 $lang = LANGUAGE_ID;
198
199 if (self::isBitrix24())
200 {
201 $lang = \CBitrix24::getLicensePrefix();
202 }
203 elseif (Loader::includeModule('intranet'))
204 {
205 $lang = \CIntranetUtils::getPortalZone();
206 }
207 elseif (Option::get('main', 'vendor') === '1c_bitrix')
208 {
209 $lang = 'ru';
210 }
211
212 return in_array($lang, ['ru', 'by', 'kz'], true);
213 }
214
220 public static function isCatalogServicesEnabled(): bool
221 {
222 return self::isFeatureEnabled(self::CATALOG_SERVICES);
223 }
224
230 public static function isStoreBatchEnabled(): bool
231 {
233 }
234
235 public static function getLandingLimitVariable(): string
236 {
237 return self::LANDING_PRODUCT_LIMIT_VARIABLE;
238 }
239
245 public static function getProductSetsHelpLink(): ?array
246 {
247 return self::getHelpLink(self::PRODUCT_SETS);
248 }
249
255 public static function getPriceQuantityRangesHelpLink(): ?array
256 {
257 return self::getHelpLink(self::EXTENDED_PRICES);
258 }
259
265 public static function getMultiPriceTypesHelpLink(): ?array
266 {
267 return self::getHelpLink(self::MULTI_PRICE_TYPES);
268 }
269
275 public static function getMultiStoresHelpLink(): ?array
276 {
277 return self::getHelpLink(self::MULTI_WARENHOUSES);
278 }
279
285 public static function getInventoryManagementHelpLink(): ?array
286 {
287 return self::getHelpLink(self::INVENTORY_MANAGEMENT);
288 }
289
295 public static function getProductLimitHelpLink(): ?array
296 {
297 return self::getHelpLink(self::PRODUCT_LIMIT);
298 }
299
305 public static function getAccessControllerHelpLink(): ?array
306 {
307 return self::getHelpLink(self::CATALOG_PERMISSIONS);
308 }
309
315 public static function getCatalogServicesHelpLink(): ?array
316 {
317 return self::getHelpLink(self::CATALOG_SERVICES);
318 }
319
325 public static function initUiHelpScope(): void
326 {
327 if (!self::isBitrix24())
328 {
329 return;
330 }
331 if (self::$helpCodesCounter <= 0 || self::$initUi)
332 {
333 return;
334 }
335 if (Loader::includeModule('ui'))
336 {
337 self::$initUi = true;
338 Main\UI\Extension::load('ui.info-helper');
339 }
340 }
341
348 private static function isFeatureEnabled(string $featureId): bool
349 {
350 if ($featureId === '')
351 {
352 return false;
353 }
354
355 $result = true;
356 if (self::isBitrix24())
357 {
358 if (isset(self::$bitrix24exist[$featureId]))
359 {
360 $result = Bitrix24\Feature::isFeatureEnabled($featureId);
361 }
362 }
363 else
364 {
365 if (isset(self::$retailExist[$featureId]))
366 {
367 $result = \CBXFeatures::IsFeatureEnabled(self::$tranferList[$featureId]);
368 }
369 }
370
371 return $result;
372 }
373
380 private static function getHelpLink(string $featureId): ?array
381 {
382 if (!self::isBitrix24())
383 {
384 return null;
385 }
386 if (!isset(self::$bitrix24helpCodes[$featureId]))
387 {
388 return null;
389 }
390 self::$helpCodesCounter++;
391 return [
392 'TYPE' => 'ONCLICK',
393 'LINK' => 'top.BX.UI.InfoHelper.show(\''.self::$bitrix24helpCodes[$featureId].'\');',
394 'FEATURE_CODE' => self::$bitrix24helpCodes[$featureId],
395 ];
396 }
397
404 private static function isBitrix24(): bool
405 {
406 if (self::$bitrix24Included === null)
407 self::$bitrix24Included = Loader::includeModule('bitrix24');
408 return self::$bitrix24Included;
409 }
410}
static getProductLimitHelpLink()
Определения feature.php:295
static isCumulativeDiscountsEnabled()
Определения feature.php:128
static initUiHelpScope()
Определения feature.php:325
static isAccessControllerCheckingEnabled()
Определения feature.php:185
static getMultiStoresHelpLink()
Определения feature.php:275
static isInventoryManagementEnabled()
Определения feature.php:148
static getAccessControllerHelpLink()
Определения feature.php:305
static getLandingProductLimit()
Определения feature.php:82
static getPriceQuantityRangesHelpLink()
Определения feature.php:255
static getCatalogServicesHelpLink()
Определения feature.php:315
static isMultiStoresEnabled()
Определения feature.php:138
static isCanUseYandexExport()
Определения feature.php:195
static getMultiPriceTypesHelpLink()
Определения feature.php:265
static isCatalogServicesEnabled()
Определения feature.php:220
static getInventoryManagementHelpLink()
Определения feature.php:285
static checkInventoryManagementFeatureByCurrentMode()
Определения feature.php:153
static getLandingLimitVariable()
Определения feature.php:235
static getProductSetsHelpLink()
Определения feature.php:245
static isStoreBatchEnabled()
Определения feature.php:230
static isMultiPriceTypesEnabled()
Определения feature.php:118
static isCommonProductProcessingEnabled()
Определения feature.php:170
static isProductSetsEnabled()
Определения feature.php:98
static isPriceQuantityRangesEnabled()
Определения feature.php:108
static load($extNames)
Определения extension.php:16
static IsFeatureEnabled($_1488512778)
Определения include.php:116
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if(!defined('SITE_ID')) $lang
Определения include.php:91
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393