33 private const OPTION_DEFAULT_SUBSCRIBE =
'default_subscribe';
34 private const OPTION_DEFAULT_PRODUCT_VAT_INCLUDED =
'default_product_vat_included';
35 private const OPTION_DEFAULT_CAN_BUY_ZERO =
'default_can_buy_zero';
36 private const OPTION_DEFAULT_QUANTITY_TRACE =
'default_quantity_trace';
37 private const OPTION_PRODUCT_CARD_SLIDER_ENABLED =
'product_card_slider_enabled';
39 private const PRODUCT_SLIDER_HELP_LINK_EU =
'https://training.bitrix24.com/support/training/course/index.php?COURSE_ID=178&LESSON_ID=25692';
40 private const PRODUCT_SLIDER_HELP_LINK_RU =
'https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=48&LESSON_ID=25488';
46 if (Loader::includeModule(
'crm'))
48 if (is_array($this->data[
'reservationSettings']))
50 if (Manager::isOnecMode())
52 foreach ($this->data[
'reservationSettings'] as $entityCode => $reservationSettingsValue)
54 if (isset($reservationSettingsValue[
'autoWriteOffOnFinalize']))
56 Reservation\Config\EntityFactory::make($entityCode)
58 'autoWriteOffOnFinalize',
59 $reservationSettingsValue[
'autoWriteOffOnFinalize'],
68 foreach ($this->data[
'reservationSettings'] as $entityCode => $reservationSettingsValue)
70 Reservation\Config\EntityFactory::make($entityCode)
71 ->setValues($reservationSettingsValue)
79 if (isset($this->data[
'checkRightsOnDecreaseStoreAmount']))
81 if ($this->data[
'checkRightsOnDecreaseStoreAmount'] ===
'Y')
96 !empty($this->data[
'costPriceCalculationMethod'])
101 CostPriceCalculator::setMethod($this->data[
'costPriceCalculationMethod']);
105 '\Bitrix\Catalog\Update\ProductBatchConverter',
112 $catalogOptionSettings = [
113 'defaultQuantityTrace' => self::OPTION_DEFAULT_QUANTITY_TRACE,
114 'defaultCanBuyZero' => self::OPTION_DEFAULT_CAN_BUY_ZERO,
115 'defaultSubscribe' => self::OPTION_DEFAULT_SUBSCRIBE,
116 'defaultProductVatIncluded' => self::OPTION_DEFAULT_PRODUCT_VAT_INCLUDED,
119 if ($this->canEnableProductCardSlider())
121 $catalogOptionSettings[
'productCardSliderEnabled'] = self::OPTION_PRODUCT_CARD_SLIDER_ENABLED;
124 if (isset($this->data[
'defaultProductVatId']))
126 $this->updateDefaultVat((
int)$this->data[
'defaultProductVatId']);
131 if (!isset($this->data[
$key]))
142 public function get(): SettingsInterface
147 if (Loader::includeModule(
'crm'))
149 $data[
'reservationEntities'] = $this->getReservationEntities();
155 'costPriceCalculationMethod' => $this->getCostPriceCalculationMethodSetting(),
158 'defaultQuantityTrace' => Option::get(
'catalog', self::OPTION_DEFAULT_QUANTITY_TRACE,
'N'),
159 'defaultSubscribe' => Option::get(
'catalog', self::OPTION_DEFAULT_SUBSCRIBE,
'Y'),
160 'defaultProductVatIncluded' => Option::get(
'catalog', self::OPTION_DEFAULT_PRODUCT_VAT_INCLUDED,
'N'),
161 'defaultCanBuyZero' => Option::get(
'catalog', self::OPTION_DEFAULT_CAN_BUY_ZERO,
'N'),
162 'productCardSliderEnabled' => Option::get(
'catalog', self::OPTION_PRODUCT_CARD_SLIDER_ENABLED, self::isBitrix24() ?
'Y' :
'N'),
163 'vats' => $this->getVats(),
164 'defaultProductVatId' => $this->getDefaultProductVatId() ?? 0,
167 'storeControlMode' => Manager::getCurrentMode(),
168 'storeControlAvailableModes' => Manager::getAvailableModes(),
172 'canEnableProductCardSlider' => $this->canEnableProductCardSlider(),
173 'hasAccessToReservationSettings' =>
$accessController->check(ActionDictionary::ACTION_RESERVED_SETTINGS_ACCESS),
174 'hasAccessToCatalogSettings' =>
$accessController->check(ActionDictionary::ACTION_CATALOG_SETTINGS_ACCESS),
176 'isBitrix24' => self::isBitrix24() ?
'Y' :
'N',
179 'hasAccessToChangeCanBuyZero' =>
$accessController->check(ActionDictionary::ACTION_SELL_NEGATIVE_COMMODITIES_SETTINGS_EDIT),
180 'productsCount' => $this->getProductsCount(),
181 'busProductCardHelpLink' => self::getBusProductCardHelpLink(),
182 'configCatalogSource' => Context::getCurrent()->getRequest()->get(
'configCatalogSource'),
197 $data[
'showNegativeStoreAmountPopup'] = !empty($negativeBalanceItem);
198 if (!empty($negativeBalanceItem))
200 $productGridComponent =
'bitrix:catalog.report.store_stock.products.grid';
203 $data[
'storeBalancePopupLink'] =
getLocalPath(
'components' . $productGridPath .
'/slider.php');
207 return new self(
$data);
215 private function getDefaultProductVatId(): ?int
217 $defaultProductCatalogId = \Bitrix\Crm\Product\Catalog::getDefaultId();
219 if (!$defaultProductCatalogId)
224 $defaultProductCatalogInfo = ServiceContainer::getIblockInfo($defaultProductCatalogId);
226 return $defaultProductCatalogInfo?->getVatId();
234 private function getVats():
array
236 $currentVat = (int)$this->getDefaultProductVatId();
240 'name' => Loc::getMessage(
"CATALOG_SETTINGS_VAT_NOT_SELECTED"),
241 'selected' => $currentVat === 0,
245 0 => Loc::getMessage(
'CATALOG_SETTINGS_VAT_HINT'),
265 'value' => $row[
'ID'],
267 'selected' => $currentVat === (int)$row[
'ID'],
270 $hints[$row[
'ID']] = Loc::getMessage(
'CATALOG_SETTINGS_VAT_HINT');
278 'current' => $currentVat,
282 private function getReservationEntities():
array
286 $reservationEntities = Reservation\Config\EntityFactory::makeAllKnown();
287 foreach ($reservationEntities as $reservationEntity)
290 'code' => $reservationEntity::getCode(),
291 'name' => $reservationEntity::getName(),
293 'scheme' => $reservationEntity::getScheme(),
294 'values' => $reservationEntity->getValues(),
302 private function getCostPriceCalculationMethodSetting():
array
304 $currentMethod = CostPriceCalculator::getMethod();
305 $methodList = CostPriceCalculator::getMethodList();
311 'name' => Loc::getMessage(
'CATALOG_SETTINGS_CALCULATION_METHOD_NOT_SELECTED'),
312 'selected' => empty($currentMethod),
317 'value' => CostPriceCalculator::METHOD_AVERAGE,
318 'name' => $methodList[CostPriceCalculator::METHOD_AVERAGE],
319 'selected' => $currentMethod === CostPriceCalculator::METHOD_AVERAGE,
322 'value' => CostPriceCalculator::METHOD_FIFO,
323 'name' => $methodList[CostPriceCalculator::METHOD_FIFO],
324 'selected' => $currentMethod === CostPriceCalculator::METHOD_FIFO,
328 CostPriceCalculator::METHOD_AVERAGE => Loc::getMessage(
'CATALOG_SETTINGS_CALCULATION_METHOD_AVERAGE_HINT'),
329 CostPriceCalculator::METHOD_FIFO => Loc::getMessage(
'CATALOG_SETTINGS_CALCULATION_METHOD_FIFO_HINT'),
331 'current' => CostPriceCalculator::getMethod(),
335 private function canEnableProductCardSlider(): bool
337 if (self::isBitrix24())
339 return Option::get(
'catalog', self::OPTION_PRODUCT_CARD_SLIDER_ENABLED) !==
'Y';
351 private function updateDefaultVat(
int $defaultProductVatId): bool
355 $defaultProductCatalogId = \Bitrix\Crm\Product\Catalog::getDefaultId();
357 $defaultProductCatalogId,
359 'VAT_ID' => $defaultProductVatId,
367 if (!$updateResult->isSuccess())
375 private static function isBitrix24(): bool
377 static $isBitrix24Included;
379 if (!isset($isBitrix24Included))
381 $isBitrix24Included = Loader::includeModule(
'bitrix24');
384 return $isBitrix24Included;
387 private function getProductsCount(): int
391 $catalogList = \CCatalogProductSettings::getCatalogList();
401 private static function getBusProductCardHelpLink(): string
403 if (self::isBitrix24())
408 if (in_array(Application::getInstance()->getLicense()->getRegion(), [
'ru',
'by',
'kz'],
true))
410 return self::PRODUCT_SLIDER_HELP_LINK_RU;
413 return self::PRODUCT_SLIDER_HELP_LINK_EU;
static getRow(array $parameters)
static getList(array $parameters=array())
static update($primary, array $data)