magento – custom attribute type, file upload

Not sure where to start in this and what the best solution would be. I need to have a product attribute that supports file upload, fir the purpose of an image.

I am not looking for code, simply some advice on the best way to achieve this

4 thoughts on “magento – custom attribute type, file upload”

  1. I think you will want to create your own “tab” in the Manage->Products page in the admin app and then inside of that you will want to use a technique such as referenced here for the uploader:

    The actual process of storing the link as an attribute on the product could be either a custom attribute you define on the product and then egt/set on this new admin tab or you could look to extend the existing product model by creating your own model class and managing the save of the new model by hooking up to the product save events.

    For adding a custom tab to the Manage->Product page I started out with this example:

  2. if you want to add file upload for customer/product. just create related attribute for that and in admin you will find the option and work properly and for frontend just create the file input. upload it via magento file uploader in any directory and just save the file path in attribute. My code for customer file attribute for reference is as under:

    <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" />

    installer for file attribute

    $installer = $this;
    //$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");
            $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)



    Now upload file and just save like

            $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;

    file should be save in media,customer folder for customer file attribute if you want to use builtin functionality.

  3. Read this blog.

    From the above blog:

    Whan of the most enticipated and needed things in Magento is File upload Custom Option. As discussed last year at Magento Forum, it is not completed nor tested.

    Now, Magento already have frontend and admin part of file upload option implemented in themes. Since backend part is still missing, understand that this still doesn’t work, however, if you’re interested how it looks, read on ..

    Frontend html is found in:


    Frontend javascript code in:

    (optionFileUpload js object = asynchronous iframe upload)

    You can enable file upload custom option if you add:

    <file translate="label" module="adminhtml">
            <file translate="label" module="adminhtml">
                <label>File Upload</label>

    inside node:




    Now you have new File Upload option that you can add to product!

    We are coding module of similar functionality for one of our clients as we speak, but we have our fingers crossed to see this option in next Magento version!

Leave a Reply

Your email address will not be published. Required fields are marked *