, если вы хотите добавить загрузку файла для клиента / продукта. просто создайте связанный атрибут для этого, и в админке вы найдете опцию и будете работать правильно, а для внешнего интерфейса просто создайте файл ввода. загрузите его через magento загрузчик файлов в любой каталог и просто сохраните путь к файлу в атрибуте. Мой код для атрибута файла клиента для справки:
<label for="certificate"><?php echo $this->__('Re-Sale Certificate') ?></label>
<div class="input-box">
<input type="file" name="designer_certificate" title="<?php echo $this->__('certificate') ?>" id="designer_certificate" />
</div>
установщик для атрибута файла
$installer = $this;
$installer->startSetup();
//$installer->getConnection()->addColumn($installer->getTable('customer/entity'), 'certificate', 'varchar(100)');
$installer->removeAttribute('customer', 'designer_certificate');
$installer->addAttribute("customer", "designer_certificate", array(
"type" => "varchar",
"backend" => "",
"label" => "Designer Certificate",
"input" => "file",
"source" => "",
"visible" => true,
"required" => false,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => ""
));
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "designer_certificate");
$used_in_forms=array();
$used_in_forms[]="adminhtml_customer";
$used_in_forms[]="checkout_register";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
$used_in_forms[]="adminhtml_checkout";
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100)
;
$attribute->save();
$installer->endSetup();
конфигурация:
<global>
....
<resources>
<designercertificate_setup>
<setup>
<module>Renegade_Account</module>
<class>Mage_Customer_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</designercertificate_setup>
<designercertificate_write>
<connection>
<use>core_write</use>
</connection>
</designercertificate_write>
<designercertificate_read>
<connection>
<use>core_read</use>
</connection>
</designercertificate_read>
</resources>
....
</global>
Теперь загрузите файл и просто сохраните как
.....
$path = Mage::getBaseDir('media') . DS .'customer'. DS . 'designer-certificates' . DS;
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$filename = str_replace(' ', '_', trim($_FILES['designer_certificate']['name']));
Add a comment to this line
$uploader->save($path, $filename);
$file = "/designer-certificates/" . $filename;
$customer->setDesignerCertificate($file);
.....
файл должен быть сохранен на носителе, в папке клиента для атрибута файла клиента, если вы хотите использовать встроенные функции.