Adding attribute / attribute group from MySql setup file


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. / file mysql4-install-0.1.0.php
  2.  
  3. <?php
  4.  
  5. $installer = $this;
  6. $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
  7. $installer->startSetup();
  8. /**
  9.  * Adding Different Attributes
  10.  */
  11.  
  12. // adding attribute group
  13. //Mage_Eav_Model_Entity_Setup addAttributeGroup (mixed $entityTypeId, mixed $setId, string $name, [int $sortOrder = null])
  14. $setup->addAttributeGroup('catalog_product', 'Default', 'Special Attributes', 1000);
  15.  
  16. // the attribute added will be displayed under the group/tab Special Attributes in product edit page
  17. $setup->addAttribute('catalog_product', 'testing_attribute', array(
  18. 'group' => 'Special Attributes',
  19. 'input' => 'text',
  20. 'type' => 'text',
  21. 'label' => 'Testing',
  22. 'backend' => '',
  23. 'visible' => 1,
  24. 'required' => 0,
  25. 'user_defined' => 1,
  26. 'searchable' => 1,
  27. 'filterable' => 0,
  28. 'comparable' => 1,
  29. 'visible_on_front' => 1,
  30. 'visible_in_advanced_search' => 0,
  31. 'is_html_allowed_on_front' => 0,
  32. 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
  33. ));
  34.  
  35. $installer->endSetup();

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.