I am add a Multiselect into the custom section product insertion area.Please show below screenshot:

enter image description here

I add this multiselect into the


<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="cs_product_custom_option">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string" translate="true">cs Product Custom Option</item>
                <item name="dataScope" xsi:type="string"/>
                <item name="sortOrder" xsi:type="number">10</item>
                <item name="collapsible" xsi:type="boolean">true</item>
                <item name="opened" xsi:type="boolean">true</item>
        <field name="cs_custom_option">
            <argument name="data" xsi:type="array">
                <item name="options" xsi:type="object">cs\Customproduct\Model\Source\CustomoptionValues</item>
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="label" translate="true" xsi:type="string">Select the options</item>
                    <item name="formElement" xsi:type="string">multiselect</item>


How to save its value into the database with products ?

Thanks in a Advance

  • Add a product attribute to achieve this, that's more efficient way and simple enough too. If you need any information, please let me know. – Prathap Gunasekaran Feb 12 at 11:11
  • Hello @G Prathap it's all value is dynamic and come into the database. so attribute is not working – Hardik Makwana Feb 12 at 11:12
  • Any another solution ? – Hardik Makwana Feb 12 at 11:14
  • Did you create this attribute in Setup? – Serhii Havrylchuk Feb 12 at 11:49
  • Yes please update the question with more information exactly what you require. – Prathap Gunasekaran Feb 12 at 11:52

You should create


    namespace cs\Customproduct\Setup;

    use Magento\Eav\Setup\EavSetup;
    use Magento\Eav\Setup\EavSetupFactory;
    use Magento\Framework\Setup\InstallDataInterface;
    use Magento\Framework\Setup\ModuleContextInterface;
    use Magento\Framework\Setup\ModuleDataSetupInterface;

    class InstallData implements InstallDataInterface
        private $eavSetupFactory;

        public function __construct(EavSetupFactory $eavSetupFactory)
            $this->eavSetupFactory = $eavSetupFactory;

        public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
            $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
                    'type' => 'text',
                    'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend',
                    'frontend' => '',
                    'label' => 'Select the options',
                    'input' => 'multiselect',
                    'class' => '',                  
                    'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'source' => 'cs\Customproduct\Model\Source\CustomoptionValues',
                    'visible' => true,
                    'required' => true,
                    'user_defined' => false,
                    'default' => '',
                    'searchable' => false,
                    'filterable' => false,
                    'comparable' => false,
                    'visible_on_front' => false,
                    'used_in_product_listing' => true,
                    'unique' => false,
                    'apply_to' => ''
  • when i delete the record into the database then into attribute also delete this value ? – Hardik Makwana Feb 12 at 12:07
  • which record do you want to delete? – Serhii Havrylchuk Feb 12 at 12:08
  • In a database id 1 with "abc" I create the attribute with using your code then i delete the id 1 record then attribute have a "abc" value . i also want to delete this – Hardik Makwana Feb 12 at 12:10
  • Yes it will be deleted – Serhii Havrylchuk Feb 12 at 12:11
  • ohk i will try it – Hardik Makwana Feb 12 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.