Last active
December 26, 2018 21:17
-
-
Save jzahedieh/79ed286d87f05f6156aa to your computer and use it in GitHub Desktop.
Magento Product Attribute Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup'); | |
if (!$installer->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'attribute_name')) { | |
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'attribute_name', array( // TABLE.COLUMN: DESCRIPTION: | |
/** Standard values defined @see Mage_Eav_Model_Entity_Setup::_prepareValues() */ | |
'label' => 'Label', // eav_attribute.frontend_label admin input label | |
'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) | |
'table' => 'module/config_name', // eav_attribute.backend_table backend table (resource config format) | |
'frontend' => 'module/class_name', // eav_attribute.frontend_model admin class (module/class_name format) | |
'input' => 'input_name', // eav_attribute.frontend_input admin input type (select, text, textarea etc) | |
'frontend_class' => null, // eav_attribute.frontend_type class associated to the element. | |
'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 | |
'default' => null, // eav_attribute.default_value admin input default value | |
'unique' => false, // eav_attribute.is_unique unique value required | |
'note' => null, // eav_attribute.note admin input note (shows below input) | |
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // catalog_eav_attribute.is_global (products only) scope | |
/** Unique values defined @see Mage_Catalog_Model_Resource_Setup::_prepareValues() */ | |
'input_renderer' => 'module/class_name', // catalog_eav_attribute.frontend_input_renderer (products only) admin input renderer (otherwise input is used to resolve renderer) | |
'visible' => true, // catalog_eav_attribute.is_visible (products only) visible on admin | |
'searchable' => false, // catalog_eav_attribute.is_searchable (products only) searchable via basic search | |
'filterable' => false, // catalog_eav_attribute.is_filterable (products only) use in layered nav | |
'comparable' => false, // catalog_eav_attribute.is_comparable (products only) comparable on frontend | |
'visible_on_front' => false, // catalog_eav_attribute.is_visible_on_front (products only) visible on frontend (store) attribute table | |
'wysiwyg_enabled' => false, // catalog_eav_attribute.is_wysiwyg_enabled (products only) admin input wysiwyg enabled | |
'is_html_allowed_on_front' => true, // catalog_eav_attribute.is_visible_on_front (products only) seems obvious, but also see visible | |
'visible_in_advanced_search' => false, // catalog_eav_attribute.is_visible_in_advanced_search (products only) searchable via advanced search | |
'filterable_in_search' => false, // catalog_eav_attribute.is_filterable_in_search (products only) use in search results layered nav | |
'used_in_product_listing' => false, // catalog_eav_attribute.used_in_product_listing (products only) made available in product listing | |
'used_for_sort_by' => false, // catalog_eav_attribute.used_for_sort_by (products only) available in the 'sort by' menu | |
'apply_to' => 'simple,configurable', // catalog_eav_attribute.apply_to (products only) which product types to apply to | |
'position' => 0, // catalog_eav_attribute.position (products only) position in layered naviagtion | |
'is_configurable' => false, // catalog_eav_attribute.is_configurable (products only) used for configurable products or not | |
'used_for_promo_rules' => false, // catalog_eav_attribute.is_used_for_promo_rules (products only) available for use in promo rules | |
/** Not sure where these are defined, but are used @see Mage_Eav_Model_Entity_Setup .*/ | |
'group' => 'General', // (not a column) tab in product edit screen | |
'sort_order' => 0, // eav_entity_attribute.sort_order sort order in group | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment