5

Since quantity field is not mandatory and I want that when ever product is added/updated quantity should be there

So there is two way of fix this, either I will make it mandatory or I set default value of quantity.

Can anyone help me do it?

Thanks

4

It is not a good idea to make quantity field mandatory. Because, in virtual and downloadable products quantity field set as NULL.

So, it is good to set a default field. You can do it by this:

Add a file in app/code/Vendor/Module/view/adminhtml/ui_component/product_form.xml

code would be :

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <modal name="advanced_inventory_modal">
        <fieldset name="stock_data">
            <field name="qty">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="value" xsi:type="string">1</item>
                    </item>
                </argument>
            </field>
        </fieldset>
    </modal>
</form>
  • It cleared a lot of things. Thanks – Magedev2301 Jun 17 at 7:46

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.