1

I need to add the backend_model value of an attribute where wasn't specified in the install setup script. The missing line is:

'backend' => 'eav/entity_attribute_backend_datetime'

But so far using just this line in an upgrade script

$installer  = Mage::getResourceModel('catalog/setup', 'catalog_setup');
$installer->startSetup();

$installer->updateAttribute('catalog_product', 'custom_date', array(
'backend' => 'eav/entity_attribute_backend_datetime'));

$installer->endSetup();

Is not updating the column backend_model in the ear_attribute table. So I'm forced to use

$installer  = Mage::getResourceModel('catalog/setup', 'catalog_setup');

$installer->startSetup();

$installer->removeAttribute('catalog_product','custom_date');

$installer->addAttribute('catalog_product', 'custom_date', array(
    'label' => 'Launches - Release Date',
    'type'      => 'datetime',
    'input'     => 'date',
    'class'     => 'validate-date',
    'global'    => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'required'  => false,
    'user_defined' => false,
    'searchable' => false,
    'filterable' => false,
    'comparable' => false,
    'visible_on_front' => false,
    'unique' => false,
    'used_in_product_listing' => true,
    'backend' => 'eav/entity_attribute_backend_datetime'
));

$installer->endSetup();

Any idea if is actually possible to update the backend_model in an upgrade script.

2 Answers 2

1

I've found the solution replacing backend to backend_model but looks like a bug of Magento.

$installer->startSetup();

$installer->updateAttribute('catalog_product', 'custom_date', 'backend_model', 'eav/entity_attribute_backend_datetime');

$installer->endSetup();
0

try with this

$installer->startSetup();

$installer->updateAttribute('catalog_product', 'custom_date', 'backend', 'eav/entity_attribute_backend_datetime');

$installer->endSetup();
1
  • still not working looks with this code. Even is the most logical Commented Feb 22, 2016 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.