1

Magento 1.9.1.0 version

My Requirement is to add a new DropDown type Column in "Images" Tab in "Manage Products"Section in Admin Section.

enter image description here

It may be more helpful if anybody can tell me that how magento is saving images details and fetching them.

[EDITED]

I have gone through the detailed issue and find out that there is a function getImagesJson() in /app/code/core/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php

which is responsible to show content in Images tab, but still want to find out that how and where magento used to save data for images, i gone through saveAction() in productController, but get unsaved JSON data of new added image.

Any one can help me that how can i get value Id of newly saved image.

1

You can do that via the menu Catalog > Attributes > Manage Attributes and creating an attribute with a Dropdown type.

After that, you can add it to the attribute set of your choice in Catalog > Attributes > Manage Attribute Sets. Select your Set, then drag your attribute in the right column, and drop it in the left one, under the group "Images". Your attribute should then display in "Manage Products".

If you want to add this attribute programmatically, you can do it with an installer, and a code like that :

<?php
$installer = $this;

$installer->startSetup();

// Group : General
$attributeSetDefault = 'Default';
$attributeGroup = 'Images';
$attributeSetId = $installer->getAttributeSetId('catalog_product', $attributeSetDefault);
if($attributeSetId){
    $attributeGroupId = $installer->getAttributeGroupId('catalog_product', $attributeSetId, $attributeGroup);
}

// Attribute : attribute_code
$attributeCode = 'attribute_code';
$attribute = $installer->getAttribute('catalog_product', $attributeCode);
if (empty($attribute['attribute_id'])) {

    $options = array();
    $options['value']['option0'][0] = 'Option 0';
    $options['value']['option1'][0] = 'Option 1';

    $installer->addAttribute(
        'catalog_product',
        $attributeCode,
        array(
            'label'                         => 'Attribute',
            'type'                          => 'varchar',
            'backend'                       => 'eav/entity_attribute_backend_array',
            'frontend'                      => '',
            'input'                         => 'select',
            'frontend_class'                => '',
            'source'                        => '',
            'required'                      => false,
            'user_defined'                  => true,
            'default'                       => '',
            'unique'                        => false,
            'global'                        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
            'option'                        => $options,
        )
    );

    $attributeId = $installer->getAttributeId('catalog_product', $attributeCode);

    if($attributeGroupId && $attributeId){
        $installer->addAttributeToGroup('catalog_product', $attributeSetId, $attributeGroupId, $attributeId);
    }
}


$installer->endSetup();
|improve this answer|||||
  • Thanks buddy but what i need is not that, actually i want to add column in images tab like "label" type text, I have edited my Question – amit_game May 13 '15 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.