我已经安装了Magento CE 1.9.2.4和补丁程序(5377、1533、4788等几乎所有补丁程序)。
该问题还揭示了在自定义部分中涉及图像上传的任何自定义模块中可能/肯定发生的问题,而不仅仅是核心的magento问题。
- 现在,我通过命令行安装了最新的补丁8788之后,无法打开自定义模块的“添加/编辑”页面,该页面在8788安装之前运行良好。
当我尝试打开模块的“添加新横幅”页面时,出现以下错误:
致命错误:在第57行的/home/site_user/public_html/app/code/community/My/Module/Block/Adminhtml/Banner/Add/Tab/Image.php中的非对象上,调用成员函数setUrl()
罪魁祸首如下:
$this->getUploader()->getConfig()->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/image'))
- 另外,我在管理
Catalog > Manage Products > Any product > Images
部分看不到已经上传的产品图片。
下面是Mage_Adminhtml_Block_Media_Uploader
被调用的核心类。
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Adminhtml media library uploader
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
*/
/**
* @deprecated
* Class Mage_Adminhtml_Block_Media_Uploader
*/
class Mage_Adminhtml_Block_Media_Uploader extends Mage_Uploader_Block_Multiple
{
/**
* Constructor for uploader block
*/
public function __construct()
{
parent::__construct();
$this->getUploaderConfig()->setTarget(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/upload'));
$this->getUploaderConfig()->setFileParameterName('file');
}
}
任何人都让我知道如何用最少的代码更改来解决此问题。
getUploader
方法的内容吗?