Skip to content

Instantly share code, notes, and snippets.

@St0iK
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save St0iK/92e81825ff4a0d621601 to your computer and use it in GitHub Desktop.

Select an option

Save St0iK/92e81825ff4a0d621601 to your computer and use it in GitHub Desktop.
Creating Magento product attributes programatically
<?php
$installer = $this;
$installer->startSetup();
$this->addAttribute('catalog_product','brown_product_info',
array (
'group' => 'General',
'type' => 'text',
'visible_on_front' => true,
'label' => 'Brown Product Info',
'input' => 'textarea',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'wysiwyg_enabled' => true,
'default' => '',
'class' => '',
'backend' => '',
'source' => ''
)
);
$this->addAttribute('catalog_product','grey_product_info',
array (
'group' => 'General',
'type' => 'text',
'visible_on_front' => true,
'label' => 'Grey Product Info',
'input' => 'textarea',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'wysiwyg_enabled' => true,
'default' => '',
'backend' => '',
'class' => '',
'source' => ''
)
);
$installer->addAttribute('catalog_product', "bestseller_favourite", array(
'type' => 'varchar',
'input' => 'select',
'label' => 'Bestseller_Favourite',
'required' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'backend' => 'eav/entity_attribute_backend_array',
'visible_on_front' => true,
'option' => array (
'values' => array(
0 => 'Bestseller',
1 => 'Favourite',
2 => 'none',
)
),
));
$installer->endSetup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment