title: How to create attribute in magento
body: <p>How can we create an attribute for product programatically in magento CE 1.9? I have been trying out multiple ways for creating an attribute for product that has a boolean value by default set to false and assigned to Default attribute set, but not visible/editable by any admin panel user.</p>
  
  <p>my Model/Resource/Eav/Mysql4/Setup.php</p>
  
  <pre><code>    &lt;?php
  
  class Mofosys_Quickbuy_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup {
  protected function _prepareValues($attr) {
      $data = parent::_prepareValues($attr);
      $data = array_merge($data, array(
  
          'apply_to'                      =&gt; $this-&gt;_getValue($attr, 'apply_to'),
          'frontend_input_renderer'       =&gt; $this-&gt;_getValue($attr, 'input_renderer'),
          'is_comparable'                 =&gt; $this-&gt;_getValue($attr, 'comparable', 0),
          'is_configurable'               =&gt; $this-&gt;_getValue($attr, 'is_configurable', 0),
          'is_filterable'                 =&gt; $this-&gt;_getValue($attr, 'filterable', 0),
          'is_filterable_in_search'       =&gt; $this-&gt;_getValue($attr, 'filterable_in_search', 0),
          'is_global'                     =&gt; $this-&gt;_getValue(
              $attr,
              'global',
              Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL
              ),
          'is_html_allowed_on_front'      =&gt; $this-&gt;_getValue($attr, 'is_html_allowed_on_front', 0),
          'is_searchable'                 =&gt; $this-&gt;_getValue($attr, 'searchable', 0),
          'is_used_for_promo_rules'       =&gt; $this-&gt;_getValue($attr, 'used_for_promo_rules', 0),
          'is_visible'                    =&gt; $this-&gt;_getValue($attr, 'visible', 0),
          'is_visible_on_front'           =&gt; $this-&gt;_getValue($attr, 'visible_on_front', 0),
          'is_wysiwyg_enabled'            =&gt; $this-&gt;_getValue($attr, 'wysiwyg_enabled', 0),
          'is_visible_in_advanced_search' =&gt; $this-&gt;_getValue($attr, 'visible_in_advanced_search', 0),
          'position'                      =&gt; $this-&gt;_getValue($attr, 'position', 0),
          'used_for_sort_by'              =&gt; $this-&gt;_getValue($attr, 'used_for_sort_by', 0),
          'used_in_product_listing'       =&gt; $this-&gt;_getValue($attr, 'used_in_product_listing', 0),
          ));
      return $data;
  }
  }
  
  ?&gt;
  </code></pre>
  
  <p>my etc/config.xml</p>
  
  <pre><code>    &lt;global&gt;
          &lt;resources&gt;
              &lt;mofosys_quickbuy_setup&gt;
                  &lt;setup&gt;
                      &lt;module&gt;Mofosys_Quickbuy&lt;/module&gt;
                  &lt;class&gt;Mofosys_Quickbuy_Model_Resource_Eav_Mysql4_Setup&lt;/class&gt;
                  &lt;/setup&gt;
              &lt;/mofosys_quickbuy_setup&gt;
          &lt;/resources&gt;
      &lt;/global&gt;
  </code></pre>
  
  <p>my sql/mofosys_quickbuy_setup/install-0.0.1.php</p>
  
  <pre><code>    &lt;?php
  // Installer file to create an attribute name "approved" inside Default attribute set
  $installer = $this;
  $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
  $installer-&gt;startSetup();
  
  
  // the attribute added will be displayed under the group/tab Special Attributes in product edit page
  $setup-&gt;addAttribute('catalog_product', 'approved', array(
      'group'                         =&gt;          'Default',
      'input'                         =&gt;          'select',
      'type'                          =&gt;          'int',
      'default'                       =&gt;          '0',
      'label'                         =&gt;          'Testing',
      'backend'                       =&gt;          '',
      'visible'                       =&gt;          0,
      'required'                      =&gt;          0,
      'user_defined'                  =&gt;          0,
      'searchable'                    =&gt;          0,
      'filterable'                    =&gt;          0,
      'comparable'                    =&gt;          0,
      'visible_on_front'              =&gt;          0,
      'visible_in_advanced_search'    =&gt;          0,
      'is_html_allowed_on_front'      =&gt;          0,
      'global'                        =&gt;          Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
  ));
  
  
  $installer-&gt;endSetup();
  
  ?&gt;
  </code></pre>