0

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.

0

try with this

$installer->startSetup();

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

$installer->endSetup();
  • still not working looks with this code. Even is the most logical – Elio Ermini Feb 22 '16 at 14:25
0

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();

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.