First, I created the UI component: Vendor/Module/view/adminhtml/ui_component/product_form.xml

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="product-details">
       <container name="fieldname_container">
           <argument name="data" xsi:type="array">
               <item name="config" xsi:type="array">
                   <item name="sortOrder" xsi:type="number">160</item>
           <field name="fieldname" formElement="multiselect">
               <argument name="data" xsi:type="array">
                   <item name="config" xsi:type="array">
                        <item name="dataScope" xsi:type="string">fieldname</item>
                        <item name="filterOptions" xsi:type="boolean">true</item>
                        <item name="showCheckbox" xsi:type="boolean">true</item>
                        <item name="disableLabel" xsi:type="boolean">false</item>
                        <item name="multiple" xsi:type="boolean">true</item>
                       <rule name="validate-field" xsi:type="boolean">true</rule>
                   <label translate="true">Field label</label>
                           <options class="Vendor\Module\Model\Backend\Product\Source\FieldName"/>

however when I save product the values of the custom attribute are not saved.

Created attribute and added it to product but now I have that field twice in product form. ( values are being saved )

If I remove created field from attribute set values are not being saved.

what is wrong here ?

1 Answer 1


Perhaps I misunderstand you. However if you use setup script you shouldn't need any XML. It's the same as manually adding product attribute via backend. The attribute data is in the db. No XML.


                'type' => 'int',
                'backend' => '',
                'frontend' => '',
                'label' => 'Featured Product',
                'input' => 'boolean',
                'class' => '',
                'source' => '',
                'global' => 0,
                'visible' => true,
                'required' => false,
                'user_defined' => true,
                'default' => null,
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false,
                'apply_to' => '',
                'system' => 1,
                'group' => 'General',
                'option' => ['values' => [""]]
  • i need xml for this attribute, need to add additional html, logic and some javascript. Jul 22, 2019 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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