Skip to content

Inventory Stock item

I am trying to add a custom field to the MSI source item. Please check the following screenshot-

enter image description here

I have overwrite product_form.xml in app/Vendor/Module/view/adminhtml/ui_component/product_form.xml as follows –

<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="sources" sortOrder="5" component="Magento_InventoryCatalogAdminUi/js/product/form/source-items">
        
        <dynamicRows name="assigned_sources" component="Magento_Ui/js/dynamic-rows/dynamic-rows-grid" template="ui/dynamic-rows/templates/grid" sortOrder="20">
            
            <container name="record" component="Magento_Ui/js/dynamic-rows/record">           
                
                <field name="custom1" formElement="input" sortOrder="51">
                    <settings>
                        <dataType>text</dataType>
                        <dataScope>custom1</dataScope>
                        <label translate="true">Custom Stock Status 1</label>                        
                        <disabled>false</disabled>
                                                
                    </settings>
                </field>
                           
            </container>
            
        </dynamicRows>
        
    </fieldset>
    
</form>

And added field as custom1 in databases table inventory_source_item using following code in /etc/db_scema.xml

<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    
    
    <table name="inventory_source_item" resource="default" engine="innodb">
        
        <column xsi:type="varchar" name="custom1" nullable="false" length="255"/>
        
    </table>
    
</schema>

But custom field data not saving in databases. Please help me about this.