In my Magento ce 1.9.2.1 website, I have created many product custom attributes by setup-upgrade scripts like below:
<?php
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$installer->addAttributeGroup('catalog_product', 'Business Directory', 'Business Directory', 1000);
$attribute_set_id = $installer->getAttributeSetId('catalog_product', 'Business Directory');
$attribute_group_id = $installer->getAttributeGroupId('catalog_product', $attribute_set_id, 'Business Directory');
$installer->addAttribute('catalog_product', 'city', array(
'label' => 'City',
'type' => 'varchar',
'attribute_set' => 'Business Directory',
'input' => 'select',
'default' => '',
'backend' => 'eav/entity_attribute_backend_array',
'frontend' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => true,
'searchable' => false,
'filterable' => '1',
'comparable' => false,
'visible_on_front' => false,
'visible_in_advanced_search' => false,
'unique' => false,
'option' => array (
0 => array("Please Select City...")
),
));
$installer->updateAttribute('catalog_product', 'city', 'is_filterable', 1);
$attribute_id = $installer->getAttributeId('catalog_product', 'city');
$installer->addAttributeToSet($entityTypeId = 'catalog_product', $attribute_set_id, $attribute_group_id, $attribute_id);
$installer->addAttribute('catalog_product', 'postcode', array(
'label' => 'Postcode',
'type' => 'varchar',
'attribute_set' => 'Business Directory',
'input' => 'select',
'default' => '',
'backend' => 'eav/entity_attribute_backend_array',
'frontend' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => true,
'searchable' => false,
'filterable' => '1',
'comparable' => false,
'visible_on_front' => false,
'visible_in_advanced_search' => false,
'unique' => false,
'option' => array (
0 => array("Please Select Postcode...")
),
));
$installer->updateAttribute('catalog_product', 'postcode', 'is_filterable', 1);
$attribute_id = $installer->getAttributeId('catalog_product', 'postcode');
$installer->addAttributeToSet($entityTypeId = 'catalog_product', $attribute_set_id, $attribute_group_id, $attribute_id);
$installer->endSetup();
unset($installer);
As you can see, both the attributes are select
(dropdown) and both have no values initially when they are created(this is my custom key criteria, empty attributes dropdown only).
But when I populate them programmatically from frontend form, their values doesn't show up in Admin >> Catalog >> Attributes in their forms. They still show no options in admin, why ?