protected function _beforeDelete() { $collection = Mage::getModel('customer/attribute')->getCollection(); $alias = Mage::helper('amcustomerattr')->getProperAlias($collection->getSelect()->getPart('from'), 'eav_attribute'); $collection->addFieldToFilter($alias . 'is_user_defined', 1); $collection->addFieldToFilter($alias . 'entity_type_id', Mage::getModel('eav/entity')->setType('customer')->getTypeId()); $collection->addFieldToFilter($alias . 'frontend_input', 'file'); foreach ($collection as $attribute) { if ($value = $this->getData($attribute->getAttributeCode())) { Mage::helper('amcustomerattr')->deleteFile($value); } } parent::_beforeDelete(); }
protected function _beforeDelete() { $collection = Mage::getModel('customer/attribute')->getCollection(); $filters = array("is_user_defined = 1", "entity_type_id => " . Mage::getModel('eav/entity')->setType('customer')->getTypeId(), "frontend_input = 'file' "); $collection = Mage::helper('amcustomerattr')->addFilters($collection, 'eav_attribute', $filters); foreach ($collection as $attribute) { if ($value = $this->getData($attribute->getAttributeCode())) { Mage::helper('amcustomerattr')->deleteFile($value); } } parent::_beforeDelete(); }