Viktor Hesselbom

Viktor Hesselbom

« Go back home

Magento: Custom attributes with image upload

Following my previous post on creating custom category attributes, here's a short explanation on how you can choose image upload as input method instead of just plain text.

What I changed from my previous code to get this working if that first I changed the type of attribute to 'image' and set backend as 'catalog/category_attribute_backend_image', like so:

$setup->addAttribute('catalog_category', 'custom_attribute', array(
    'group' => 'Custom Tab',
    'input' => 'image',
    'type' => 'varchar',
    'label' => 'Custom Attribute',
    'backend' => 'catalog/category_attribute_backend_image',
    'visible' => 1,
    'required' => 0,
    'user_defined' => 1,
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

And that's all there is to it. Now you should have a custom attribute field where you can upload an image.