The goal of this article is to show to add new image type to product in Magento.
By default Magento has 3 type of images:
- Base image
- Small image
- Thumbnail image
Typically these types of images is sufficient. But sometimes it becomes necessary to add a new type of image. Add a new type of image is easy as Magento in the gallery displays all the attributes for which the attribute ‘input_type’ equals ‘media_image’.
Code, described below adds a new type of image «small_image_two». It should be executed as an SQL update.
<?php
$installer = $this;
$installer->startSetup();
$this->addAttribute(
'catalog_product',
'small_image_two',
array (
'group' => 'Images',
'type' => 'varchar',
'frontend' => 'catalog/product_attribute_frontend_image',
'label' => 'Small Image Two',
'input' => 'media_image',
'class' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
)
);
$installer->endSetup();
After adding the attribute you will see the following:

This is the place for you to tell a litle bit about your self. Just write your name, age, hobbies or anything else.
Horaayy..there are 10 comment(s) for me so far ;)
hi,
where i can execute this code?
thanks
hello, t0th
You should execute it in sql update script. Please, see as example any file in the folder: /app/code/core/Mage/Catalog/sql/catalog_setup
having a hard time getting this. how do I actually run the script? it looks like it runs when Mage_catalog is updated but how to I do that. I tried running ./pear intall Mage_Catalog and ./pear upgrade Mage_Catalog Any help would be appreciated.
thanks
I need to know how to execute the update SQL script?
I agree with others, the instructions are lacking.
I get it that files in /app/code/core/Mage/Catalog/sql/catalog_setup/ are in same format but it does not help newbie.
If I create own file to that directory and throw the code above to there it does not magically get executed, I need to know how to execute the update SQL?
Btw if it is just SQL why not paste SQL statements those are simple to execute with phpmyadmin…
How to i start the “Magento update script”?
How do i start the “Magento update script”?
the best way is too reinstall magento.
Put the new code in
app\code\core\Mage\Resource\Eav\Mysql4\Setup.php line: 888
So,
I got this working by creating a custom module. Adding this to my custom module setup.
My config.xml looked like:
0.1.0
Renove_Vectorimage
Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
core_setup
Thanks.. Great Code..:)
Great, exactly what I was looking for, although a companion post on where to put the code might be helpful to all the commenters above!