I want to add 2 groups and their attributes programmatically to an existing Set Group This is the screenshot.
Please note that I am willing to add two Groups each one containing 3 attributes the first one and 4 the second one. * The groups are not exisiting, Only the Attribute Set exist This is my essay :
<?php /* @var $conn Varien_Db_Adapter_Interface */ /* @var $installer Mage_Catalog_Model_Resource_Setup */$installer = $this;$installer->startSetup(); /** * Entities */$productEntity = Mage_Catalog_Model_Product::ENTITY; $installer->addAttribute($productEntity, 'gen2', array( 'type' => 'int', 'group' => 'General2', 'backend' => '', 'frontend' => '', 'label' => 'label1', 'input' => 'select', 'class' => '', 'note' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'source' => "eav/entity_attribute_source_table", 'apply_to' => array('simple', 'configurable', 'bundle'), 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => '0', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => true, 'unique' => false, ));$installer->endSetup();$attribute = Mage::getSingleton('eav/config')->getAttribute($productEntity, 'gen2');$options = array( "0", "1", "2", "3", ); foreach ($options as $key => $option) { $installer->addAttributeOption(array( 'attribute_id' => $attribute->getId(), 'value' => array( "option-" . $key => array(0 => $option) ) )); }
Please note that only the group set (like Attset in the image) is existing and the groups and their attributes are inexistant. Also should I run the script from shell command? Thanks in advance