142 private $localeCurrency;
180 $optionData[static::FIELD_IS_USE_DEFAULT] = !
$option->getData(static::FIELD_STORE_TITLE_NAME);
185 $value->setData(static::FIELD_IS_USE_DEFAULT, !
$value->getData(static::FIELD_STORE_TITLE_NAME));
190 static::FIELD_PRICE_NAME,
196 return array_replace_recursive(
199 $this->locator->getProduct()->getId() => [
200 static::DATA_SOURCE_DEFAULT => [
201 static::FIELD_ENABLE => 1,
202 static::GRID_OPTIONS_NAME =>
$options 249 $this->meta = array_replace_recursive(
252 static::GROUP_CUSTOM_OPTIONS_NAME => [
256 'label' =>
__(
'Customizable Options'),
258 'dataScope' => static::GROUP_CUSTOM_OPTIONS_SCOPE,
259 'collapsible' =>
true,
262 static::GROUP_CUSTOM_OPTIONS_PREVIOUS_NAME,
263 static::GROUP_CUSTOM_OPTIONS_DEFAULT_SORT_ORDER
277 $this->meta = array_merge_recursive(
303 'template' =>
'ui/form/components/complex',
304 'sortOrder' => $sortOrder,
305 'content' =>
__(
'Custom options let customers choose the product variations they want.'),
310 static::BUTTON_IMPORT => [
314 'title' =>
__(
'Import Options'),
317 'component' =>
'Magento_Ui/js/form/components/button',
320 'targetName' =>
'ns=' . static::FORM_NAME .
', index=options',
321 'actionName' =>
'clearDataProvider' 324 'targetName' =>
'ns=' . static::FORM_NAME .
', index=' 325 . static::IMPORT_OPTIONS_MODAL,
326 'actionName' =>
'openModal',
329 'targetName' =>
'ns=' . static::CUSTOM_OPTIONS_LISTING
330 .
', index=' . static::CUSTOM_OPTIONS_LISTING,
331 'actionName' =>
'render',
334 'displayAsLink' =>
true,
340 static::BUTTON_ADD => [
344 'title' =>
__(
'Add Option'),
347 'component' =>
'Magento_Ui/js/form/components/button',
351 'targetName' =>
'${ $.ns }.${ $.ns }.' . static::GROUP_CUSTOM_OPTIONS_NAME
352 .
'.' . static::GRID_OPTIONS_NAME,
353 'actionName' =>
'processingAddChild',
377 'addButtonLabel' =>
__(
'Add Option'),
379 'component' =>
'Magento_Catalog/js/components/dynamic-rows-import-custom-options',
380 'template' =>
'ui/dynamic-rows/templates/collapsible',
381 'additionalClasses' =>
'admin__field-wide',
382 'deleteProperty' => static::FIELD_IS_DELETE,
383 'deleteValue' =>
'1',
384 'addButton' =>
false,
385 'renderDefaultRecord' =>
false,
386 'columnsHeader' =>
false,
387 'collapsibleHeader' =>
true,
388 'sortOrder' => $sortOrder,
389 'dataProvider' => static::CUSTOM_OPTIONS_LISTING,
390 'imports' => [
'insertData' =>
'${ $.provider }:${ $.dataProvider }'],
399 'headerLabel' =>
__(
'New Option'),
401 'component' =>
'Magento_Ui/js/dynamic-rows/record',
402 'positionProvider' => static::CONTAINER_OPTION .
'.' . static::FIELD_SORT_ORDER_NAME,
403 'isTemplate' =>
true,
404 'is_collection' =>
true,
409 static::CONTAINER_OPTION => [
414 'collapsible' =>
true,
449 'dataScope' => static::FIELD_ENABLE,
452 'sortOrder' => $sortOrder,
473 'provider' => static::FORM_NAME .
'.product_form_data_source',
475 'title' =>
__(
'Select Product'),
478 'text' =>
__(
'Import'),
479 'class' =>
'action-primary',
482 'targetName' =>
'index = ' . static::CUSTOM_OPTIONS_LISTING,
483 'actionName' =>
'save' 494 static::CUSTOM_OPTIONS_LISTING => [
498 'autoRender' =>
false,
499 'componentType' =>
'insertListing',
500 'dataScope' => static::CUSTOM_OPTIONS_LISTING,
501 'externalProvider' => static::CUSTOM_OPTIONS_LISTING .
'.' 502 . static::CUSTOM_OPTIONS_LISTING .
'_data_source',
503 'selectionsProvider' => static::CUSTOM_OPTIONS_LISTING .
'.' 504 . static::CUSTOM_OPTIONS_LISTING .
'.product_columns.ids',
505 'ns' => static::CUSTOM_OPTIONS_LISTING,
506 'render_url' => $this->urlBuilder->getUrl(
'mui/index/render'),
507 'realTimeLink' =>
true,
508 'externalFilterMode' =>
false,
509 'currentProductId' => $this->locator->getProduct()->getId(),
515 'currentProductId' =>
'${ $.externalProvider }:params.current_product_id' 540 'component' =>
'Magento_Ui/js/form/components/group',
541 'breakLine' =>
false,
542 'showLabel' =>
false,
543 'additionalClasses' =>
'admin__field-group-columns admin__control-group-equal',
544 'sortOrder' => $sortOrder,
556 'label' =>
__(
'Option Title'),
557 'component' =>
'Magento_Catalog/component/static-type-input',
558 'valueUpdate' =>
'input',
560 'optionId' =>
'${ $.provider }:${ $.parentScope }.option_id',
561 'isUseDefault' =>
'${ $.provider }:${ $.parentScope }.is_use_default' 573 if ($this->locator->getProduct()->getStoreId()) {
574 $useDefaultConfig = [
576 'template' =>
'Magento_Catalog/form/element/helper/custom-option-service',
579 $titlePath = $this->arrayManager->findPath(static::FIELD_TITLE_NAME, $commonContainer,
null)
580 . static::META_CONFIG_PATH;
581 $commonContainer = $this->arrayManager->merge($titlePath, $commonContainer, $useDefaultConfig);
584 return $commonContainer;
602 'component' =>
'Magento_Ui/js/form/components/group',
603 'breakLine' =>
false,
604 'showLabel' =>
false,
605 'additionalClasses' =>
'admin__field-group-columns admin__control-group-equal',
606 'sortOrder' => $sortOrder,
607 'fieldTemplate' =>
'Magento_Catalog/form/field',
638 'optionId' =>
'${ $.provider }:${ $.parentScope }.option_id',
639 'optionTypeId' =>
'${ $.provider }:${ $.parentScope }.option_type_id',
640 'isUseDefault' =>
'${ $.provider }:${ $.parentScope }.is_use_default' 643 'template' =>
'Magento_Catalog/form/element/helper/custom-option-type-service',
654 'addButtonLabel' =>
__(
'Add Value'),
656 'component' =>
'Magento_Ui/js/dynamic-rows/dynamic-rows',
657 'additionalClasses' =>
'admin__field-wide',
658 'deleteProperty' => static::FIELD_IS_DELETE,
659 'deleteValue' =>
'1',
660 'renderDefaultRecord' =>
false,
661 'sortOrder' => $sortOrder,
671 'component' =>
'Magento_Ui/js/dynamic-rows/record',
672 'positionProvider' => static::FIELD_SORT_ORDER_NAME,
673 'isTemplate' =>
true,
674 'is_collection' =>
true,
681 $this->locator->getProduct()->getStoreId() ?
$options : []
683 static::FIELD_PRICE_NAME => $this->getPriceFieldConfigForSelectType(20),
709 'dataScope' => static::FIELD_OPTION_ID,
710 'sortOrder' => $sortOrder,
728 return array_replace_recursive(
733 'label' =>
__(
'Title'),
736 'dataScope' => static::FIELD_TITLE_NAME,
738 'sortOrder' => $sortOrder,
740 'required-entry' =>
true 763 'label' =>
__(
'Option Type'),
765 'formElement' => Select::NAME,
766 'component' =>
'Magento_Catalog/js/custom-options-type',
767 'elementTmpl' =>
'ui/grid/filters/elements/ui-select',
768 'selectType' =>
'optgroup',
769 'dataScope' => static::FIELD_TYPE_NAME,
771 'sortOrder' => $sortOrder,
773 'disableLabel' =>
true,
775 'selectedPlaceholders' => [
776 'defaultPlaceholder' =>
__(
'-- Please select --'),
779 'required-entry' => true
783 'values' => [
'field',
'area'],
785 static::CONTAINER_TYPE_STATIC_NAME,
786 static::FIELD_PRICE_NAME,
787 static::FIELD_PRICE_TYPE_NAME,
788 static::FIELD_SKU_NAME,
789 static::FIELD_MAX_CHARACTERS_NAME
793 'values' => [
'file'],
795 static::CONTAINER_TYPE_STATIC_NAME,
796 static::FIELD_PRICE_NAME,
797 static::FIELD_PRICE_TYPE_NAME,
798 static::FIELD_SKU_NAME,
799 static::FIELD_FILE_EXTENSION_NAME,
800 static::FIELD_IMAGE_SIZE_X_NAME,
801 static::FIELD_IMAGE_SIZE_Y_NAME
805 'values' => [
'drop_down',
'radio',
'checkbox',
'multiple'],
807 static::GRID_TYPE_SELECT_NAME
811 'values' => [
'date',
'date_time',
'time'],
813 static::CONTAINER_TYPE_STATIC_NAME,
814 static::FIELD_PRICE_NAME,
815 static::FIELD_PRICE_TYPE_NAME,
816 static::FIELD_SKU_NAME
839 'label' =>
__(
'Required'),
842 'dataScope' => static::FIELD_IS_REQUIRE_NAME,
844 'sortOrder' => $sortOrder,
871 'dataScope' => static::FIELD_SORT_ORDER_NAME,
874 'sortOrder' => $sortOrder,
896 'sortOrder' => $sortOrder
916 'label' =>
__(
'Price'),
918 'component' =>
'Magento_Catalog/js/components/custom-options-component',
920 'dataScope' => static::FIELD_PRICE_NAME,
923 'addbeforePool' => $this->productOptionsPrice->prefixesToOptionArray(),
924 'sortOrder' => $sortOrder,
926 'validate-number' => true
940 private function getPriceFieldConfigForSelectType(
int $sortOrder)
943 $priceFieldConfig[
'arguments'][
'data'][
'config'][
'template'] =
'Magento_Catalog/form/field';
945 return $priceFieldConfig;
958 return array_replace_recursive(
963 'label' =>
__(
'Price Type'),
964 'component' =>
'Magento_Catalog/js/components/custom-options-price-type',
966 'formElement' => Select::NAME,
967 'dataScope' => static::FIELD_PRICE_TYPE_NAME,
969 'sortOrder' => $sortOrder,
970 'options' => $this->productOptionsPrice->toOptionArray(),
995 'label' =>
__(
'SKU'),
998 'dataScope' => static::FIELD_SKU_NAME,
1000 'sortOrder' => $sortOrder,
1020 'label' =>
__(
'Max Characters'),
1023 'dataScope' => static::FIELD_MAX_CHARACTERS_NAME,
1025 'sortOrder' => $sortOrder,
1027 'validate-zero-or-greater' => true
1048 'label' =>
__(
'Compatible File Extensions'),
1049 'notice' =>
__(
'Enter separated extensions, like: png, jpg, gif.'),
1052 'dataScope' => static::FIELD_FILE_EXTENSION_NAME,
1054 'sortOrder' => $sortOrder,
1056 'required-entry' =>
true,
1077 'label' =>
__(
'Maximum Image Size'),
1078 'notice' =>
__(
'Please leave blank if it is not an image.'),
1079 'addafter' =>
__(
'px.'),
1080 'component' =>
'Magento_Catalog/js/components/custom-options-component',
1083 'dataScope' => static::FIELD_IMAGE_SIZE_X_NAME,
1085 'sortOrder' => $sortOrder,
1087 'validate-zero-or-greater' => true
1109 'addafter' =>
__(
'px.'),
1110 'component' =>
'Magento_Catalog/js/components/custom-options-component',
1113 'dataScope' => static::FIELD_IMAGE_SIZE_Y_NAME,
1115 'sortOrder' => $sortOrder,
1117 'validate-zero-or-greater' => true
1136 foreach ($this->productOptionsConfig->getAll() as
$option) {
1138 'value' => $groupIndex,
1145 if (
$type[
'disabled']) {
1150 $group[
'optgroup'][] = [
'label' =>
$type[
'label'],
'value' =>
$type[
'name']];
1153 if (count(
$group[
'optgroup'])) {
1170 return $this->storeManager->getStore()->getBaseCurrency()->getCurrencySymbol();
1180 private function getLocaleCurrency()
1182 if ($this->localeCurrency ===
null) {
1185 return $this->localeCurrency;
1197 if (!is_numeric(
$value)) {
1201 $store = $this->storeManager->getStore();
1202 $currency = $this->getLocaleCurrency()->getCurrency(
$store->getBaseCurrencyCode());
1203 $value = $currency->toCurrency(
$value, [
'display' => \
Magento\Framework\Currency::NO_SYMBOL]);