Studyon Minte9.com
Magento




Add an EAV-Attribute



include 'app/Mage.php';

	Mage::app();
<?php

	$c = array (
	  'entity_type_id'  => 11,         
	  // 11 is the id of the entity model "sales/order". 
	  // This could be different on your system! Look at database-table "eav_entity_type" for the correct ID!
	  'attribute_code'  => 'myorder_customercomment',
	  'backend_type'    => 'text',     // MySQL-DataType
	  'frontend_input'  => 'textarea', // Type of the HTML-Form-Field
	  'is_global'       => '1',
	  'is_visible'      => '1',
	  'is_required'     => '0',
	  'is_user_defined' => '0',
	  'frontend_label'  => 'Customer Comment',
	);
	$attribute = new Mage_Eav_Model_Entity_Attribute();
	$attribute->loadByCode($c['entity_type_id'], $c['attribute_code'])
			  ->setStoreId(0)
			  ->addData($c);
	$attribute->save();


http://www.magentocommerce.com/boards/viewthread/10268