Public Member Functions | |
beforeSave ($object) |
Definition at line 35 of file Image.php.
beforeSave | ( | $ | object | ) |
Enter description here...
Varien_Object | $object |
???
Reimplemented from Mage_Eav_Model_Entity_Attribute_Backend_Abstract.
Definition at line 43 of file Image.php.
00044 { 00045 $value = $object->getData($this->getAttribute()->getName()); 00046 00047 if (is_array($value) && !empty($value['delete'])) { 00048 $object->setData($this->getAttribute()->getName(), ''); 00049 $this->getAttribute()->getEntity() 00050 ->saveAttribute($object, $this->getAttribute()->getName()); 00051 return; 00052 } 00053 00054 $path = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; 00055 00056 try { 00057 $uploader = new Varien_File_Uploader($this->getAttribute()->getName()); 00058 $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png')); 00059 $uploader->setAllowRenameFiles(true); 00060 $uploader->save($path); 00061 00062 $object->setData($this->getAttribute()->getName(), $uploader->getUploadedFileName()); 00063 $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName()); 00064 } catch (Exception $e) { 00065 /** @TODO ??? */ 00066 return; 00067 } 00068 00069 }