Following various browser dropping Flash support, Magento have responded with a new module Mage_Uploader. This deprecates the class Mage_Adminhtml_Block_Media_Uploader
In the case of Magestore_Giftvoucher , the following error is now thrown :
Fatal error: Call to a member function setUrl() on null in …../public/app/code/local/Magestore/Giftvoucher/Block/Product/Upload.php on line 39
In order the resolve this bug you firstly need to extend from the new class Mage_Uploader_Block_Multiple and add the following method to the file since this method no longer exists in the new class:
1 2 3 4 5 6 7 |
public function getConfig() { if (is_null($this->_config)) { $this->_config = new Varien_Object(); } return $this->_config; } |
As of yet Magestore have not released a patch for this module. I’d obviously suggest rewriting this class correctly. Rather than modifying the module directly.
Config.xml
1 2 3 4 5 6 7 |
... <giftvoucher> <rewrite> <product_upload>Vendor_Namespace_Block_Giftvoucher_Product_Upload</product_upload> </rewrite> </giftvoucher> ... |
Vendor/Namespace/Block/Giftvoucher/Product/Upload.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
<?php /** * Override to fix use of deprecated class Mage_Adminhtml_Block_Media_Uploader */ /** * Class Vendor_Namespace_Block_Giftvoucher_Product_Upload */ class Vendor_Namespace_Block_Giftvoucher_Product_Upload extends Mage_Uploader_Block_Multiple { protected $_config; public function __construct() { parent::__construct(); $this->setId($this->getId() . '_Uploader'); $this->setTemplate(''); $this->getConfig()->setUrl( $this->getUrl('giftvoucher/index/customUpload') ); $this->getConfig()->setParams(); $this->getConfig()->setFileField('image'); $this->getConfig()->setFilters( array( 'images' => array( 'label' => Mage::helper('adminhtml')->__( 'Images (.gif, .jpg, .png)' ), 'files' => array('*.gif', '*.jpg', '*.png') ) ) ); $this->getConfig()->setWidth(32); } public function getDeleteButtonHtml() { $this->setChild( 'delete_button', $this->getLayout()->createBlock('adminhtml/widget_button') ->addData( array( 'id' => '{{id}}-delete', 'class' => 'delete', 'type' => 'button', 'label' => Mage::helper('adminhtml')->__(''), 'onclick' => $this->getJsObjectName() . '.removeFile(\'{{fileId}}\')', 'style' => 'display:none' ) ) ); return $this->getChildHtml('delete_button'); } public function getDataMaxSize() { $dataSize = Mage::helper('giftvoucher')->getInterfaceConfig( 'upload_max_size' ); if (is_nan($dataSize) || $dataSize <= 0) { $dataSize = 500; } return $dataSize . 'K'; } public function getConfig() { if (is_null($this->_config)) { $this->_config = new Varien_Object(); } return $this->_config; } } |