Return to Snippet

Revision: 35466
at November 8, 2010 23:22 by TioSolid


Initial Code
/ file mysql4-install-0.1.0.php
 
<?php
 
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
/**
 * Adding Different Attributes
 */
 
// adding attribute group
//Mage_Eav_Model_Entity_Setup   addAttributeGroup  (mixed $entityTypeId, mixed $setId, string $name, [int $sortOrder = null]) 
$setup->addAttributeGroup('catalog_product', 'Default', 'Special Attributes', 1000);
 
// the attribute added will be displayed under the group/tab Special Attributes in product edit page
$setup->addAttribute('catalog_product', 'testing_attribute', array(
    'group'         => 'Special Attributes',
    'input'         => 'text',
    'type'          => 'text',
    'label'         => 'Testing',
    'backend'       => '',
    'visible'       => 1,
    'required'      => 0,
    'user_defined' => 1,
    'searchable' => 1,
    'filterable' => 0,
    'comparable'    => 1,
    'visible_on_front' => 1,
    'visible_in_advanced_search'  => 0,
    'is_html_allowed_on_front' => 0,
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
 
$installer->endSetup();

Initial URL
http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/

Initial Description

                                

Initial Title
Adding attribute / attribute group from MySql setup file

Initial Tags
magento

Initial Language
PHP