0

after migration my site, i found one strenge issue that when i saved product it not save,

after debbugging i found that

product has custom option of type file

and Compatible File Extensions is required filed,

http://prntscr.com/izo2fm

how to set it to not required

2
  • Have someone found real fix for this problem?
    – Mikg
    Commented Sep 9, 2018 at 12:14
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review
    – Jarnail S
    Commented Sep 9, 2018 at 14:51

1 Answer 1

2

You want to change only in Magento version 2.2 or greater.

Create etc/adminhtml/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions" type="vendor\module\Ui\DataProvider\Product\Form\Modifier\CustomOptions" />
</config>

Please overwrite CustomOptions.php in your vendor/module/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php

And find getFileExtensionFieldConfig function. remove this the code from that function,

'validation' => [
    'required-entry' => true,
],

After execute php bin/magento cache:clean and check your admin panel.

I hope this will help you.

8
  • Editing directly a core file is not a good way. You should write a plugin or modify that option in the own class which will be injected in the global configuration (ui components pool of that form). Commented Apr 2, 2018 at 11:27
  • getFileExtensionFieldConfig() Commented Apr 2, 2018 at 11:33
  • Ill check in version 2.1.6 but its not required in than version, so can you tell me in which version its change to required Commented Apr 2, 2018 at 11:36
  • Provide link if you have of change log Commented Apr 2, 2018 at 11:39
  • In Magento2.1.6, it is by default non-require. Commented Apr 2, 2018 at 11:41

Your Answer

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

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