21 private const FIELD_ID_PREFIX =
'product_';
23 private const FIELD_NAME_PREFIX =
'PRODUCT_';
25 private const PRODUCT_FIELD_NAME =
'PRODUCT_FIELD_NAME';
51 $this->catalogIncluded = Loader::includeModule(
'catalog');
52 if ($this->catalogIncluded)
54 $this->catalogConfig = \CCatalogSku::GetInfoByIBlock($this->iblockId);
55 if (empty($this->catalogConfig))
57 $this->catalogConfig =
null;
59 $this->catalogOptions[
'SEPARATE_MODE'] = Main\Config\Option::get(
'catalog',
'show_catalog_tab_with_offers') ===
'Y';
60 $this->catalogOptions[
'STORE_MODE'] = Catalog\Config\State::isUsedInventoryManagement();
85 $this->productFieldHandlers = [
87 'QUANTITY_TRACE' =>
'QuantityTrace',
88 'CAN_BUY_ZERO' =>
'CanBuyZero',
89 'QUANTITY' =>
'Quantity',
90 'PURCHASING_PRICE' =>
'PurchasingPrice',
91 'VAT_INCLUDED' =>
'VatIncluded',
93 'SUBSCRIBE' =>
'Subscribe',
94 'MEASURE' =>
'Measure'
103 $result = parent::getActionHandlers();
104 $result[Catalog\Grid\ProductAction::SET_FIELD] =
'ProductField';
105 $result[Catalog\Grid\ProductAction::CHANGE_PRICE] =
'ProductChangePrice';
106 if (Main\
Config\Option::get(
'catalog',
'enable_convert_product_to_service') ===
'Y')
108 $result[Catalog\Grid\ProductAction::CONVERT_PRODUCT_TO_SERVICE] =
'ConvertProductToService';
109 $result[Catalog\Grid\ProductAction::CONVERT_SERVICE_TO_PRODUCT] =
'ConvertServiceToProduct';
127 if ($this->catalogConfig[
'CATALOG_TYPE'] !== \CCatalogSku::TYPE_PRODUCT)
129 foreach ($this->productFieldHandlers as $handler)
131 $handler =
'getProductField' . $handler .
'Row';
132 if (is_callable([$this, $handler]))
134 $row = call_user_func_array([$this, $handler], []);
141 unset($row, $handler);
146 $userFields = Catalog\Product\SystemField::getGroupActions($this);
147 if (!empty($userFields) && is_array($userFields))
149 $items = array_merge($items, $userFields);
155 $name = (isset($params[
'NAME']) && $params[
'NAME'] !=
''
162 'TYPE' => Main\Grid\Panel\Types::DROPDOWN,
170 'APPLY_BUTTON_ID' =>
'send_product',
171 'CONFIRM_MESSAGE' =>
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_SET_PRODUCT_FIELD_CONFIRM'),
177 'type' =>
'multicontrol',
180 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS
183 'ACTION' => Main\Grid\Panel\Actions::CREATE,
207 if (strncmp($fieldId,
'UF_', 3) === 0)
209 return Catalog\Product\SystemField::getGroupActionRequest($this, $fieldId);
212 if (!isset($this->productFieldHandlers[$fieldId]))
217 $handler =
'getProductField'.$this->productFieldHandlers[$fieldId].
'Request';
218 if (is_callable([$this, $handler]))
220 return call_user_func_array([$this, $handler], []);
235 $name = (isset($params[
'NAME']) && $params[
'NAME'] !=
''
242 'type' =>
'customJs',
243 'js' =>
'CreateDialogChPrice()'
253 $result[
'PRICE_TYPE'] = $this->request->get(
'chprice_id_price_type');
254 $result[
'UNITS'] = $this->request->get(
'chprice_units');
255 $result[
'FORMAT_RESULTS'] = $this->request->get(
'chprice_format_result');
256 $result[
'INITIAL_PRICE_TYPE'] = $this->request->get(
'chprice_initial_price_type');
257 $result[
'RESULT_MASK'] = $this->request->get(
'chprice_result_mask');
258 $result[
'DIFFERENCE_VALUE'] = $this->request->get(
'chprice_difference_value');
259 $result[
'VALUE_CHANGING'] = $this->request->get(
'chprice_value_changing_price');
260 return (!empty($result[
'VALUE_CHANGING']) ? $result :
null);
274 $params[
'APPLY_BUTTON_ID'] =
'convert_product_to_service_confirm';
275 $params[
'CONFIRM_MESSAGE'] =
276 Catalog\Config\State::isUsedInventoryManagement()
277 ?
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_CONVERT_PRODUCT_TO_SERVICE_CONFIRM_WITH_INVENTORY')
278 :
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_CONVERT_PRODUCT_TO_SERVICE_CONFIRM_WITHOUT_INVENTORY')
282 'name' => (string)($params[
'NAME'] ??
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_CONVERT_PRODUCT_TO_SERVICE')),
283 'type' =>
'multicontrol',
286 'ACTION' => Main\
Grid\Panel\Actions::RESET_CONTROLS
289 'ACTION' => Main\
Grid\Panel\Actions::CREATE,
307 $params[
'APPLY_BUTTON_ID'] =
'convert_service_to_product_confirm';
308 $params[
'CONFIRM_MESSAGE'] =
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_CONVERT_SERVICE_TO_PRODUCT_CONFIRM_MESSAGE_MSGVER_1');
311 'name' => (string)($params[
'NAME'] ??
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_CONVERT_SERVICE_TO_PRODUCT')),
312 'type' =>
'multicontrol',
315 'ACTION' => Main\
Grid\Panel\Actions::RESET_CONTROLS
318 'ACTION' => Main\
Grid\Panel\Actions::CREATE,
330 return self::PRODUCT_FIELD_NAME;
347 return self::FIELD_NAME_PREFIX.mb_strtoupper($field);
356 return self::FIELD_ID_PREFIX.mb_strtolower($field).
'_id';
369 'IBLOCK_GRID_PANEL_ACTION_MESS_STATUS_DEFAULT',
370 [
'#VALUE#' => $defaultState
379 'VALUE' => Catalog\ProductTable::STATUS_YES
383 'VALUE' => Catalog\ProductTable::STATUS_NO
398 'VALUE' => Catalog\ProductTable::STATUS_YES
402 'VALUE' => Catalog\ProductTable::STATUS_NO
413 if (!$this->catalogIncluded)
417 if (empty($this->catalogConfig))
433 $entity = Catalog\ProductTable::getEntity();
434 $field = $entity->getField($fieldId);
438 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS
441 'ACTION' => Main\Grid\Panel\Actions::CREATE,
444 'TYPE' => Main\Grid\Panel\Types::TEXT,
452 'NAME' => $field->getTitle(),
454 'ONCHANGE' => $action
457 unset($field, $entity);
471 $entity = Catalog\ProductTable::getEntity();
472 $field = $entity->getField($fieldId);
476 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS
479 'ACTION' => Main\Grid\Panel\Actions::CREATE,
482 'TYPE' => Main\Grid\Panel\Types::DROPDOWN,
491 'NAME' => $field->getTitle(),
493 'ONCHANGE' => $action
496 unset($field, $entity);
519 if ($result ===
null)
521 return [
'WEIGHT' => $result];
529 if ($this->catalogOptions[
'STORE_MODE'])
535 Main\
Config\Option::get(
'catalog',
'default_quantity_trace') ===
'Y'
548 return [
'QUANTITY_TRACE' => $result];
556 if ($this->catalogOptions[
'STORE_MODE'])
562 Main\
Config\Option::get(
'catalog',
'default_can_buy_zero') ===
'Y'
573 if (!is_string($result))
577 return [
'CAN_BUY_ZERO' => $result];
585 if ($this->catalogOptions[
'STORE_MODE'])
598 if ($result ===
null)
600 return [
'QUANTITY' => $result];
608 if ($this->catalogOptions[
'STORE_MODE'])
610 if (!AccessController::getCurrent()->check(ActionDictionary::ACTION_PRODUCT_PURCHASE_INFO_VIEW))
616 foreach (
Currency\CurrencyManager::getCurrencyList() as $currencyId => $currencyName)
619 'VALUE' => $currencyId,
620 'NAME' => $currencyName
626 $entity = Catalog\ProductTable::getEntity();
627 $field = $entity->getField(
'PURCHASING_PRICE');
631 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS
634 'ACTION' => Main\Grid\Panel\Actions::CREATE,
637 'TYPE' => Main\Grid\Panel\Types::TEXT,
643 'TYPE' => Main\Grid\Panel\Types::DROPDOWN,
652 'NAME' => $field->getTitle(),
653 'VALUE' =>
'PURCHASING_PRICE',
654 'ONCHANGE' => $action
657 unset($field, $entity);
678 if (!is_string($currency))
680 $currency = trim($currency);
681 if ($currency ===
'')
684 return [
'PURCHASING_PRICE' => $price,
'PURCHASING_CURRENCY' => $currency];
706 return [
'VAT_INCLUDED' => $result];
720 $iterator = Catalog\VatTable::getList([
721 'select' => [
'ID',
'NAME',
'SORT'],
722 'filter' => [
'=ACTIVE' =>
'Y'],
723 'order' => [
'SORT' =>
'ASC',
'ID' =>
'ASC']
725 while ($row = $iterator->fetch())
729 'VALUE' => $row[
'ID'],
730 'NAME' => $row[
'NAME']
733 unset($row, $iterator);
748 $result = $this->
checkIntValue($this->request->get($this->getFormRowFieldName(
'VAT_ID')));
749 if ($result ===
null || $result < 0)
751 return [
'VAT_ID' => $result];
762 Main\
Config\Option::get(
'catalog',
'default_subscribe') ===
'Y'
773 if (!is_string($result))
777 return [
'SUBSCRIBE' => $result];
786 $iterator = \CCatalogMeasure::getList(
791 array(
'ID',
'CODE',
'MEASURE_TITLE',
'SYMBOL_INTL')
793 while($row = $iterator->Fetch())
796 'VALUE' => $row[
'ID'],
797 'NAME' => $row[
'MEASURE_TITLE']
800 unset($row, $iterator);
815 $result = $this->
checkIntValue($this->request->get($this->getFormRowFieldName(
'MEASURE')));
816 if ($result ===
null || $result <= 0)
818 return [
'MEASURE' => $result];
830 if (is_array($value) || $value ===
null)
832 $value = (str_replace([
',',
' '], [
'.',
''], trim($value)));
835 $value = (float)$value;
836 return (is_finite($value) ? $value :
null);
848 if (is_array($value) || $value ===
null)
850 $value = trim($value);
853 $value = (float)(str_replace(
',',
'.', $value));
854 return (is_finite($value) ? $value :
null);
891 if (is_array($value) || $value ===
null)
895 if (((
int)$value).
'|' !== $value.
'|')
actionConvertServiceToProductPanel(array $params=[])
getProductFieldQuantityTraceRow()
getProductFieldWeightRequest()
__construct(array $options)
actionConvertProductToServicePanel(array $params=[])
static checkIntValue($value)
static checkFloatValue($value)
getProductFieldSubscribeRow()
static getStatusList(bool $defaultState)
getProductFieldQuantityRow()
actionProductFieldRequest()
getDropdownField(string $fieldId, array $list)
static checkEmptyFloatValue($value)
getProductFieldCanBuyZeroRow()
getProductFieldMeasureRequest()
getProductFieldQuantityRequest()
getProductFieldPurchasingPriceRow()
getProductFieldVatIncludedRequest()
actionProductChangePricePanel(array $params=[])
getProductFieldCanBuyZeroRequest()
getProductFieldSubscribeRequest()
getInputField(string $fieldId)
getProductFieldQuantityTraceRequest()
actionProductChangePriceRequest()
getProductFieldVatIdRequest()
getProductFieldVatIncludedRow()
getFormProductFieldName()
getProductFieldWeightRow()
actionProductFieldPanel(array $params=[])
getFormRowFieldId(string $field)
initProductFieldHandlers()
static checkBinaryValue($value)
getProductFieldVatIdRow()
getFormRowFieldName(string $field)
static checkStatusValue($value)
isAllowedProductActions()
getProductFieldMeasureRow()
getProductFieldPurchasingPriceRequest()
getApplyButtonWithConfirm(array $params)
static getMessage($code, $replace=null, $language=null)