Aoe_FilePicker
Aoe_FilePicker copied to clipboard
Not compatible with Supee-8788 patch
I had to disable Aoe_FilePicker because after installing Supee-8788 patch product image upload in admin was not working
Mage_Adminhtml_Block_Media_Uploader is deprecated after SUPEE-8788 (and Magento 1.9.3). Thus there are several backward incompatibility changes which breaks module using the uploader.
I've solved the problem by adding a new rewrite in config.xml under the blocks
<uploader>
<rewrite>
<multiple>Aoe_FilePicker_Block_FilePicker</multiple>
</rewrite>
</uploader>
I've also modified FilePicker.php to the following
if (class_exists("Mage_Uploader_Block_Abstract")) {
// PATCH SUPEE-8788 or Magento 1.9.3
class Aoe_FilePicker_Block_FilePicker extends Mage_Uploader_Block_Multiple {
/**
* Constructor
*/
public function __construct() {
parent::__construct();
$this->setTemplate('media/filepicker.phtml');
}
/**
* Get filepicker.io API key
*
* @return string
*/
public function getApiKey() {
return Mage::getStoreConfig('admin/aoe_filepicker/apikey');
}
/**
* Get active filepicker.io services
*
* @return array
*/
public function getServices() {
return Mage::getStoreConfig('admin/aoe_filepicker/services');
}
}
}
else {
class Aoe_FilePicker_Block_FilePicker extends Mage_Adminhtml_Block_Media_Uploader {
/**
* Constructor
*/
public function __construct() {
parent::__construct();
$this->setTemplate('media/filepicker.phtml');
}
/**
* Get filepicker.io API key
*
* @return string
*/
public function getApiKey() {
return Mage::getStoreConfig('admin/aoe_filepicker/apikey');
}
/**
* Get active filepicker.io services
*
* @return array
*/
public function getServices() {
return Mage::getStoreConfig('admin/aoe_filepicker/services');
}
}
}
in filepicker.phtml I've added also the ckecking and the modifications accordingly
<?php
if (class_exists("Mage_Uploader_Block_Abstract")) {
// PATCH SUPEE-8788 or Magento 1.9.3
?>
var _uploads = {
data: <?php echo $this->getJsonConfig(); ?>,
removeFile: function() {}
}
Event.observe('<?php echo $this->getHtmlId() ?>-button', 'click', function(event) {
filepicker.getFile('image/*', {
'multiple': true,
'modal': true,
'services': [<?php echo $this->getServices() ?>]
}, function(response) {
// take the response from filepicker.io and pass send it to Magento via Ajax
new Ajax.Request(_uploads.data.uploaderConfig.target, {
method: 'post',
parameters: {fp_response: JSON.stringify(response) },
onSuccess: function(transport) {
transport.responseText.evalJSON().each(function(item) {
media_gallery_contentJsObject.handleUploadComplete([{response: Object.toJSON(item)}])
});
},
onFailure: function() { alert('Something went wrong...') }
});
});
Event.stop(event);
});
<?php
}
else {
?>
<?php echo $this->getJsObjectName() ?> = {
data: <?php echo $this->getConfigJson() ?>,
removeFile: function() {}
}
Event.observe('<?php echo $this->getHtmlId() ?>-button', 'click', function(event) {
filepicker.getFile('image/*', {
'multiple': true,
'modal': true,
'services': [<?php echo $this->getServices() ?>]
}, function(response) {
// take the response from filepicker.io and pass send it to Magento via Ajax
new Ajax.Request(<?php echo $this->getJsObjectName() ?>.data.url, {
method: 'post',
parameters: {fp_response: JSON.stringify(response) },
onSuccess: function(transport) {
transport.responseText.evalJSON().each(function(item) {
media_gallery_contentJsObject.handleUploadComplete([{response: Object.toJSON(item)}])
});
},
onFailure: function() { alert('Something went wrong...') }
});
});
Event.stop(event);
});
<?php
}
?>