不确定从哪里开始以及最佳解决方案是什么。我需要一个支持文件上传的产品属性,以达到图像的目的。
我不是在寻找代码,只是关于实现此目的的最佳方法的一些建议
答案 0 :(得分:2)
我认为您需要在管理应用中的Manage-> Products页面中创建自己的“标签”,然后在其中您将要使用此处引用的技术作为上传者:
http://www.magentocommerce.com/boards/viewthread/11667/P0/
将链接作为属性存储在产品上的实际过程可以是您在产品上定义的自定义属性,然后在此新的管理选项卡上进行设置/设置,或者您可以通过创建自己来扩展现有的产品模型拥有模型类并通过连接到产品保存事件来管理新模型的保存。
要将自定义标签添加到Manage->产品页面,我开始使用此示例:
答案 1 :(得分:1)
创建一个新属性并在其中存储文件路径,并在GUI中为该
提供文件上载字段答案 2 :(得分:1)
如果您要为客户/产品添加文件上传。只需为此创建相关属性,在管理员中,您将找到该选项并正常工作,并为前端创建文件输入。通过任何目录中的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);
.....
如果要使用内置功能,文件应保存在媒体,客户文件夹中,用于客户文件属性。
答案 3 :(得分:0)
阅读此blog。
Magento中最受欢迎和需要的东西是文件上传自定义选项。作为Magento论坛的discussed last year,它没有完成也没有经过测试。
现在,Magento已经在主题中实现了文件上传选项的前端和管理部分。由于后端部分仍然缺失,请了解这仍然不起作用,但是,如果您对它的外观感兴趣,请继续阅读..
前端html位于:
应用程序/设计/前端/默认/默认/模板/目录/产品/视图/选项/类型/ file.phtml
前端的JavaScript代码:
app / design / frontend / default / default / template / catalog / product / view / options.phtml
(optionFileUpload js object =异步iframe上传)
如果您添加以下内容,则可以启用文件上传自定义选项
<file translate="label" module="adminhtml">
<label>File</label>
<render>adminhtml/catalog_product_edit_tab_options_type_file</render>
<types>
<file translate="label" module="adminhtml">
<label>File Upload</label>
</file>
</types>
</file>
内部节点:
config-&GT;全球 - &GT;目录 - &GT;产品 - &GT;选项 - &GT;定做基团
在:
应用程序/代码/核心/法师/目录的/ etc / config.xml中
现在您可以添加新的“文件上载”选项,以便添加到产品中!
我们正在为我们的一位客户编写类似功能的编码模块,但我们已经指出了下一个Magento版本中的这个选项!