This is because there is no code that will do this in the Magento core. The controller that does the product save action is in the file app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
. Here you will find the code snippet.
/**
* Initialize product options
*/
if (isset($productData['options']) && !$product->getOptionsReadonly()) {
$product->setProductOptions($productData['options']);
}
$product->setCanSaveCustomOptions(
(bool)$this->getRequest()->getPost('affect_product_custom_options')
&& !$product->getOptionsReadonly()
);
All this is doing is setting the options on the product option and doing no image upload.
Then when you look at app/code/core/Mage/Catalog/Model/Product.php
there is the function _beforeSave
this function does the actual processing on options before saving them. What it does is loops through all the options and then adds them.
$this->getOptionInstance()->addOption($option);
So there is no code for uploading images or even saving them against the option itself. You will need to extend the options table to add your custom item, or use a custom model for storing option images.
Then what I would suggest is to listen to the admin event catalog_product_prepare_save
. This is fired after the options are set on the product. It has the product object and the request. You can use this event to perform the actual image upload and then update the product object if you need to.
I took a quick look and I think you have to work around this class \Magento\Catalog\Model\Product\Option
, there is a method called addValue()
which is a public function. You might do a plugin.
Hope it helps.
Best Answer
Please follow below steps:
Step1: First of all keep back up "CustomOptions.php" from the below mentioned path
i.e
Magento2Root/vendor/magento/module-catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php
Step 2: Please follow the below github link and download the file and place the same in the respected (mentioned) path. Click Here Github Link
Step 3: Please create a database column in the name of 'qty_option' for the below 2 tables
catalog_product_option
catalog_product_option_type_value
Step 4: Clear cache and page_cache and re login into admin and check the same.
Note: Once it works using meld tool identify the changes what i did in the CustomOptions.php
Using plugin concept try to achieve the same from your end. Thanks