Another option inspired by Mondane's answer:
- copy /app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php to / app / code / local / Mage / Catalog / Model / Category / Attribute / Backend / Image.php
- (if you don't have a CREATE IT path)
then edit the created file
replace the afterSave function with this code
public function afterSave($object) { $value = $object->getData($this->getAttribute()->getName()); if (is_array($value) && !empty($value['delete'])) { $object->setData($this->getAttribute()->getName(), ''); $this->getAttribute()->getEntity() ->saveAttribute($object, $this->getAttribute()->getName()); return; } if (!isset($_FILES) || count($_FILES) == 0) { return; } $path = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; try { $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName()); $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png')); $uploader->setAllowRenameFiles(true); $result = $uploader->save($path); $object->setData($this->getAttribute()->getName(), $result['file']); $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName()); } catch (Exception $e) { if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) { Mage::logException($e); } return; } } }
by doing this, you will replace the magenta code without getting involved in the main files, beacause magento will take this file automatically before taking the source file
source share