We used the following method, to create a custom field for the product custom option section: https://devhooks.in/blog/magento2-how-to-add-custom-field-in-custom-option
This works fine, but we can not define the value for a store view specific.
How can we modify the code, to save different values for store views?
See our; CustomOptions\Plugin\Catalog\Ui\DataProvider\Product\Form\Modifier
<?php
namespace Module\CustomOptions\Plugin\Catalog\Ui\DataProvider\Product\Form\Modifier;
class CustomOptions
{
public function afterModifyMeta(
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions $subject,
$meta
) {
$meta['custom_options']['children']['options']['children']['record']['children']['container_option']['children']['container_common']['children']['custom_text'] =
$this->getTitleFieldConfig(
200,
[
'arguments' => [
'data' => [
'config' => [
'label' => __('Description'),
'componentType' => \Magento\Ui\Component\Form\Field::NAME,
'formElement' => \Magento\Ui\Component\Form\Element\Textarea::NAME,
'valueUpdate' => 'input',
'imports' => [
'optionId' => '${ $.provider }:${ $.parentScope }.option_id'
]
],
],
],
]
);
return $meta;
}
/**
* Get config for "Title" fields
*
* @param int $sortOrder
* @param array $options
* @return array
*/
protected function getTitleFieldConfig($sortOrder, array $options = [])
{
return array_replace_recursive(
[
'arguments' => [
'data' => [
'config' => [
'label' => __('Description'),
'componentType' => \Magento\Ui\Component\Form\Field::NAME,
'formElement' => \Magento\Ui\Component\Form\Element\Textarea::NAME,
'dataScope' => 'description',
'dataType' => \Magento\Ui\Component\Form\Element\DataType\Text::NAME,
'sortOrder' => $sortOrder,
'validation' => [
'required-entry' => false
],
],
],
],
],
$options
);
}
}