7

I Have tried to add new image upload attribute to Magento Product using sql upgrade script, but I got the error message like:

Invalid backend model specified: catalog/product_attribute_backend_image

The file has name upgrade-0.0.1-0.0.2.php which is correct because I see new version in core_resource table.

There is my code:

$installer = $this;
$installer->startSetup();
$this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'image_cert', array(
    'type' => 'varchar',
    'group' => 'Design',
    'label' => 'Certificate Image',
    'input' => 'image',
    'backend' => 'catalog/product_attribute_backend_image',
    'required' => false,
    'sort_order' => 55,
    'global' => 1
));
$installer->endSetup();

What I'm doing wrong?

2

Try this code (base image attribute)

<?php
$setup = new Mage_Catalog_Model_Resource_Setup('core_setup');

$attr = array (
  'attribute_model' => NULL,
  'backend' => NULL,
  'type' => 'varchar',
  'table' => NULL,
  'frontend' => 'catalog/product_attribute_frontend_image',
  'input' => 'media_image',
  'label' => 'Base Image',
  'frontend_class' => NULL,
  'source' => NULL,
  'required' => '0',
  'user_defined' => '0',
  'default' => NULL,
  'unique' => '0',
  'note' => NULL,
  'input_renderer' => NULL,
  'global' => '0',
  'visible' => '1',
  'searchable' => '0',
  'filterable' => '0',
  'comparable' => '0',
  'visible_on_front' => '0',
  'is_html_allowed_on_front' => '0',
  'is_used_for_price_rules' => '0',
  'filterable_in_search' => '0',
  'used_in_product_listing' => '0',
  'used_for_sort_by' => '0',
  'is_configurable' => '1',
  'apply_to' => NULL,
  'visible_in_advanced_search' => '0',
  'position' => '0',
  'wysiwyg_enabled' => '0',
  'used_for_promo_rules' => '0',
  'tooltip' => NULL,
  'max_len' => '0',
  'option' => 
  array (
    'values' => 
    array (
    ),
  ),
);
$setup->addAttribute('catalog_product', 'image', $attr);

$attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'image');
$attribute->setStoreLabels(array (
));
$attribute->save();
0

You can create attribute from backend itself:

  1. Catalog > Attributes > Manage Attributes > Create New Attribute
  2. Select Catalog Input Type for Store Owner as Media Image
  3. Put this attribute in Image Group of your attribute set.
  4. Do Index Management
  5. Clear caches
1
  • 1
    thanks, but this way is not right. I explain you. For example I have live / stage / dev / local versions of my site. In this case I have to repeat your solution 4 site * 5 steps = 20 iterations. But I can do it by upgrade-x.x.x-x.x.y and it will be more correct
    – Oleg
    Jul 12 '16 at 7:36

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.