Finally i found solution for more than one image upload in that custom form.Its simple concept for adding image upload more than one in custom form.Here following procedure for that image upload concept:
Step:1
Image file : Block/Adminhtml/Next/Edit/Tab/Image.php
add custom image field tag in that image file.
[...]
$fieldset->addField('collar_image', 'image', array(
'name' => 'collar_image',
'label' => Mage::helper('measurement_setter')->__('collar Image'),
'title' => Mage::helper('measurement_setter')->__('collar Image'),
'required' => true,
'disabled' => $isElementDisabled
));
[...]
Step:2
Controller File: controllers/Adminhtml/[ModuleName]Controller.php
Add that below line into saveAction()
function.
//Assign that values
if (isset($data['collar_image'])) {
$collar_imageData = $data['collar_image'];
unset($data['collar_image']);
} else {
$collar_imageData = array();
}
//collar Remove Image
if (isset($collar_imageData['delete']) && $model->getCollar_image()) {
$imageHelper->removeImage($model->getCollar_image());
$model->setCollar_image(null);
}
//Upload new Collar Image upload tag
$imageFile = $imageHelper->uploadImage('collar_image');
if ($imageFile) {
if ($model->getCollar_image()) {
$imageHelper->removeImage($model->getCollar_image());
}
$model->setCollar_image($imageFile);
}
And then you can clear cache and index section in Var/Cache
and Var/Index
.
NOTICE:
[Modulename] =>your module name
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
Best Answer
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.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.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.