2

I have created the manage option attribute for product attributes. description,image and use_in_guide ina Manage Option section. I able to save the image, description but image data value is not captured in table eav_attribute_option table.

the file name is option.php

protected function _prepareUserDefinedAttributeOptionValues($option, $inputType, $defaultValues)
{
    $optionId = $option->getId();

    $value['checked'] = in_array($optionId, $defaultValues) ? 'checked="checked"' : '';
    $value['intype'] = $inputType;
    $value['id'] = $optionId;
    $value['sort_order'] = $option->getSortOrder();
    $value['description'] = $option->getDescription();
    $value['image'] = $option->getImage();
    $value['filter'] = $option->getUseInGuide();

    foreach ($this->getStores() as $store) {
        $storeId = $store->getId();
        $storeValues = $this->getStoreOptionValues($storeId);
        $value['store' . $storeId] = isset(
            $storeValues[$optionId]
        ) ? $this->escapeHtml(
            $storeValues[$optionId]
        ) : '';
    }

    return [$value];
}

enter image description here

1 Answer 1

0

I have found the answer myself, I have overridden the container.phtml and added the below-mentioned script and calling controller via ajax uploaded file in the directory.

$('body').on('change', '.inputFile', function(e) {
    var option = this.name.split("[")[1].split("]")[0];
    var fileName = e.target.files[0].name;


    var myFormData = new FormData(); 
    myFormData.append('option_image', e.target.files[0]);

    e.preventDefault();
    $.ajax({
        url: "<?php echo $block->getBaseUrl(); ?>callfilter",
        type: "POST",
        data: myFormData,
        contentType: false, 
        cache: false,
        processData:false, 
        success: function(result){
            $('#option_image_'+option).val(result.path);
        }           
    });
});

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.