Skip to content

Instantly share code, notes, and snippets.

@JosephMaxwell
Last active August 29, 2015 14:14
Show Gist options
  • Save JosephMaxwell/068bea6d3a2c85ed93e1 to your computer and use it in GitHub Desktop.
Save JosephMaxwell/068bea6d3a2c85ed93e1 to your computer and use it in GitHub Desktop.
<?php
/** @var Mage_Catalog_Model_Resource_Setup $installer **/
$installer = $this;
if (!$installer->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'attribute_name')) {
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'attribute_name', array( // TABLE.COLUMN: DESCRIPTION:
'label' => 'Label', // eav_attribute.frontend_label admin input label
'group' => 'General', // (not a column) tab in product edit screen
'sort_order' => 0, // eav_entity_attribute.sort_order sort order in group
'backend' => 'module/class_name', // eav_attribute.backend_model backend class (module/class_name format)
'type' => 'varchar', // eav_attribute.backend_type backend storage type (varchar, text etc)
'frontend' => 'module/class_name', // eav_attribute.frontend_model admin class (module/class_name format)
'note' => null, // eav_attribute.note admin input note (shows below input)
'default' => null, // eav_attribute.default_value admin input default value
'wysiwyg_enabled' => false, // catalog_eav_attribute.is_wysiwyg_enabled (products only) admin input wysiwyg enabled
'input' => 'input_name', // eav_attribute.frontend_input admin input type (select, text, textarea etc)
'input_renderer' => 'module/class_name', // catalog_eav_attribute.frontend_input_renderer (products only) admin input renderer (otherwise input is used to resolve renderer)
'source' => null, // eav_attribute.source_model admin input source model (for selects) (module/class_name format)
'required' => true, // eav_attribute.is_required required in admin
'user_defined' => false, // eav_attribute.is_user_defined editable in admin attributes section, false for not
'unique' => false, // eav_attribute.is_unique unique value required
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // catalog_eav_attribute.is_global (products only) scope
'visible' => true, // catalog_eav_attribute.is_visible (products only) visible on admin
'visible_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) visible on frontend (store) attribute table
'used_in_product_listing' => false, // catalog_eav_attribute.used_in_product_listing (products only) made available in product listing
'searchable' => false, // catalog_eav_attribute.is_searchable (products only) searchable via basic search
'visible_in_advanced_search' => false, // catalog_eav_attribute.is_visible_in_advanced_search (products only) searchable via advanced search
'filterable' => false, // catalog_eav_attribute.is_filterable (products only) use in layered nav
'filterable_in_search' => false, // catalog_eav_attribute.is_filterable_in_search (products only) use in search results layered nav
'comparable' => false, // catalog_eav_attribute.is_comparable (products only) comparable on frontend
'is_html_allowed_on_front' => true, // catalog_eav_attribute.is_visible_on_front (products only) seems obvious, but also see visible
'apply_to' => 'simple,configurable', // catalog_eav_attribute.apply_to (products only) which product types to apply to
'is_configurable' => false, // catalog_eav_attribute.is_configurable (products only) used for configurable products or not
'used_for_sort_by' => false, // catalog_eav_attribute.used_for_sort_by (products only) available in the 'sort by' menu
'position' => 0, // catalog_eav_attribute.position (products only) position in layered naviagtion
'used_for_promo_rules' => false, // catalog_eav_attribute.is_used_for_promo_rules (products only) available for use in promo rules
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment