1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
onecenabler.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\Store\EnableWizard;
4
5use Bitrix\Catalog\Access\AccessController;
6use Bitrix\Catalog\Access\ActionDictionary;
7use Bitrix\Catalog\Config\State;
8use Bitrix\Catalog\v2\Integration\Landing\ShopManager;
9use Bitrix\Crm\Integration\Sale\Reservation\Config\EntityFactory;
10use Bitrix\Main\Error;
11use Bitrix\Main\Localization\Loc;
12use Bitrix\Main\Result;
13use Bitrix\Crm\Integration\Sale\Reservation\Config\Entity\Deal;
14
15class OnecEnabler extends Enabler
16{
17 public static function enable(array $options = []): Result
18 {
19 $result = new Result();
20
21 if (!AccessController::getCurrent()->check(ActionDictionary::ACTION_PRODUCT_EDIT))
22 {
23 $result->addError(
24 new Error(
25 Loc::getMessage('ONEC_ENABLER_PRODUCT_DEACTIVATION_INSUFFICIENT_RIGHTS'),
26 0,
27 [
28 'analyticsCode' => '1c_no_access_product_edit',
29 ],
30 )
31 );
32
33 return $result;
34 }
35
36 $result = parent::enable($options);
37 if (!$result->isSuccess())
38 {
39 return $result;
40 }
41
43 (new ShopManager())->unpublishShops();
44 State::setIsExternalCatalog(true);
45 self::setDealReservationAutoMode();
46
47 return $result;
48 }
49
50 public static function disable(): Result
51 {
52 $r = parent::disable();
53 if (!$r->isSuccess())
54 {
55 return $r;
56 }
57
58 State::setIsExternalCatalog(false);
59
60 return $r;
61 }
62
63 private static function setDealReservationAutoMode(): void
64 {
65 $dealConfig = EntityFactory::make(Deal::CODE);
66
67 $values = $dealConfig->getValues();
68 if ($values[Deal::RESERVATION_MODE_CODE] !== Deal::RESERVATION_MODE_OPTION_ON_ADD_TO_DOCUMENT)
69 {
70 $values[Deal::RESERVATION_MODE_CODE] = Deal::RESERVATION_MODE_OPTION_ON_ADD_TO_DOCUMENT;
71 $dealConfig->setValues($values);
72 $dealConfig->save();
73 }
74 }
75}
static enable(array $options=[])
Определения onecenabler.php:17
Определения error.php:15
$options
Определения commerceml2.php:49
</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