Skip to content

Instantly share code, notes, and snippets.

@dinhkhanh
Last active August 29, 2015 14:16
Show Gist options
  • Save dinhkhanh/e8e2deee8a44f597761c to your computer and use it in GitHub Desktop.
Save dinhkhanh/e8e2deee8a44f597761c to your computer and use it in GitHub Desktop.
Magento: Update attributes source_model
<?php
require_once "app/Mage.php";
Mage::app();
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $installer->getEntityTypeId('catalog_product');
// replace <my_attribute_code> with your attribute code
$idAttribute = $installer->getAttribute($entityTypeId, '<your_attribute_code_here>', 'attribute_id');
$installer->updateAttribute($entityTypeId, $idAttribute, array(
'source_model' => 'yournewmodule/your_new_model'
));
// let's see if it worked
$attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', '<your_attribute_code_here>');
Zend_Debug::dump($attribute->getData());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment