Administration Way:
It is natural that a newly created attribute is not assigned to an attribute set (including the Default attribute set) automatically. You need to do it manually.
In the Admin, under Catalog > Attributes > Manage Attribute Sets.
source
Programming Way:
Try this code:
$installer = Mage::getModel('eav/entity_setup');
$installer->addAttributeToSet($entityTypeId, $setId, $groupId, $attributeId, $sortOrder);
The specifications for function addAttributeToSet:
- mixed $entityTypeId
- mixed $setId
- mixed $groupId
- mixed $attributeId
- int $sortOrder=null
- @return Mage_Eav_Model_Entity_Setup
The arguments ending with 'Id' don't actually have to be ids according to the codes. Set and group names can be transalated to ids automatically. However for the attribute, you should use code (usually written in small letters, ex. 'firstname') rather than names (ex. 'First Name').
For example, you want to add a product attribute called 'popularity' to the 'Default' attribute set under 'General' group, just write like this:
$installer = Mage::getModel('eav/entity_setup');
$installer->addAttributeToSet('catalog_product', 'Default', 'General', 'popularity');
Unfortunately I don't have an installation to test the code for the moment, hopefully it should work :)