In example below I upgraded is_visible_on_front and used_in_product_listing from false to true for two attributes namely flavor and unit_count. These attributes are product attributes and refer to Mage_Catalog_Model_Product::ENTITY or catalog_product.
For update attribute params we are need the: entity id of attribute, id of attribute, field name what we wont to change, new field value and sort order. Function what we will use is updateAttribute from class Mage_Eav_Model_Entity_Setup.
/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
$entityTypeId = $installer->getEntityTypeId(Mage_Catalog_Model_Product::ENTITY);
$attributeCodes = array('flavor', 'unit_count');
foreach ($attributeCodes as $attributeCode) {
$attributeId = $installer->getAttributeId($entityTypeId, $attributeCode);
$installer->updateAttribute($entityTypeId, $attributeId, 'is_visible_on_front', true);
$installer->updateAttribute($entityTypeId, $attributeId, 'used_in_product_listing', true);
}
$installer->endSetup(); /**
* Update Attribute data and Attribute additional data
*
* @param mixed $entityTypeId
* @param mixed $id
* @param string $field
* @param mixed $value
* @param int $sortOrder
* @return Mage_Eav_Model_Entity_Setup
*/
public function updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null)
{
$this->_updateAttribute($entityTypeId, $id, $field, $value, $sortOrder);
$this->_updateAttributeAdditionalData($entityTypeId, $id, $field, $value);
return $this;
}